Last active
March 27, 2017 17:11
-
-
Save itswadesh/b7839aa0f80c484c7ec67f63caff5ba9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('../includes/config.php'); | |
$query="select id,title,description,url,votes from posts order by id desc"; | |
$result = $mysqli->query($query) or die($mysqli->error.__LINE__); | |
$arr = array(); | |
if($result->num_rows > 0) { | |
while($row = $result->fetch_assoc()) { | |
$arr[] = $row; | |
} | |
} | |
# JSON-encode the response | |
$json_response = json_encode($arr); | |
// # Return the response | |
echo $json_response; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment