Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. $postID = $_REQUEST['pIdPost'];
  2. $result = mysqli_query($con,
  3. "SELECT
  4.  
  5. comments.IdPost, comments.IdUser,
  6. comments.Comment AS Comment , users.UserImage ,
  7. users.Username , DATE_FORMAT(comments.CommentDate, '%d/%m/%Y %H:%i:%s') AS cDate
  8.  
  9. FROM comments, users
  10.  
  11. WHERE
  12.  
  13. comments.IdPost = '$postID'
  14.  
  15. AND
  16.  
  17. users.IdUser = comments.IdUser ")or die('Errant Query:');
  18.  
  19. while($row = mysqli_fetch_assoc($result))
  20. {
  21. $output[]=$row;
  22. }
  23.  
  24. header('content-type: application/json; charset=utf-8');
  25.  
  26. print(json_encode($output, JSON_UNESCAPED_UNICODE));
  27. //print(json_encode($output));
  28. mysqli_close($con);
  29.  
  30. [{"IdPost":"2",
  31. "IdUser":"5",
  32. "Comment":"Me 3",
  33. "UserImage":"images/defaultUser.png",
  34. "Username":"Mia",
  35. "CommentDate":"16/11/2014 00:01:05"}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement