Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2. $conn = mysqli_connect("[host]","[username]","[password]","[database]") or die ("Error".mysqli_error($conn));
  3.  
  4. header('content-type: application/json');
  5.  
  6. $sql = "select * from [table_name]";
  7. $result = mysqli_query($conn, $sql) or die ("Error".mysqli_error($conn));
  8. $myArray = array();
  9. while ($row = mysqli_fetch_assoc($result)) {
  10. $myArray[] = $row;
  11. }
  12.  
  13. mysqli_close($conn);
  14.  
  15. $json = json_encode($myArray);
  16.  
  17. echo $json;
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement