Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <?php
  2. include('../includes/config.php');
  3.  
  4. $query="select id,title,description,url,votes from posts order by id desc";
  5. $result = $mysqli->query($query) or die($mysqli->error.__LINE__);
  6.  
  7. $arr = array();
  8. if($result->num_rows > 0) {
  9. while($row = $result->fetch_assoc()) {
  10. $arr[] = $row;
  11. }
  12. }
  13.  
  14. # JSON-encode the response
  15. $json_response = json_encode($arr);
  16.  
  17. // # Return the response
  18. echo $json_response;
  19.  
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement