Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_SERVER['REQUEST_METHOD']=='GET'){
- $user_id = $_GET['user_id'];
- require_once('dbConnect.php');
- $user_tags = array();
- foreach ($_REQUEST['user_id'] as $key => $val) {
- $user_tags[$key] = filter_var($val, FILTER_SANITIZE_STRING);
- }
- $user_ids = "'" . implode("','", $user_tags) . "'";
- $sql = "SELECT * FROM user_tags WHERE user_id IN ({$user_ids})";
- $r = mysqli_query($con,$sql);
- //creating a blank array
- $result = array();
- //looping through all the records fetched
- while($row = mysqli_fetch_array($r)){
- //Pushing name and id in the blank array created
- array_push($result,array(
- "tags"=>$row['tags']
- ));
- }
- //Displaying the array in json format
- echo json_encode(array('result'=>$result));
- mysqli_close($con);
- }
- $result['tags'][] = $row['tags'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement