Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. if($_SERVER['REQUEST_METHOD']=='GET'){
  4.  
  5. $user_id = $_GET['user_id'];
  6.  
  7. require_once('dbConnect.php');
  8.  
  9. $user_tags = array();
  10.  
  11. foreach ($_REQUEST['user_id'] as $key => $val) {
  12. $user_tags[$key] = filter_var($val, FILTER_SANITIZE_STRING);
  13. }
  14. $user_ids = "'" . implode("','", $user_tags) . "'";
  15. $sql = "SELECT * FROM user_tags WHERE user_id IN ({$user_ids})";
  16.  
  17. $r = mysqli_query($con,$sql);
  18.  
  19. //creating a blank array
  20. $result = array();
  21.  
  22. //looping through all the records fetched
  23. while($row = mysqli_fetch_array($r)){
  24.  
  25. //Pushing name and id in the blank array created
  26. array_push($result,array(
  27. "tags"=>$row['tags']
  28. ));
  29. }
  30.  
  31. //Displaying the array in json format
  32. echo json_encode(array('result'=>$result));
  33.  
  34. mysqli_close($con);
  35. }
  36.  
  37. $result['tags'][] = $row['tags'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement