Advertisement
Guest User

php

a guest
Nov 25th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2.     include 'connection.php';
  3.  
  4.     function get_tags($conn){
  5.         $sql = mysqli_query("SELECT distinct(tag) FROM tags");
  6.         if(mysqli_num_rows($sql)) {
  7.             $data = array();
  8.             while($row=mysqli_fetch_array($sql)) {
  9.                 $data[] = array (
  10.                     'tag' => $row['tag']);
  11.  
  12.             }
  13.         }
  14.         header('Content-type: application/json');
  15.         echo json_encode($data);
  16.     }
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement