Advertisement
Guest User

list_restoran

a guest
Mar 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. header('Content-Type: application/json');
  4.  
  5. require_once('koneksi.php');
  6.  
  7. $url_maps="http://maps.googleapis.com/maps/api/staticmap?zoom=17&size=800x300&maptype=roadmap&markers=icon:http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico|
  8. ";
  9.  
  10. $response = array();
  11.  
  12. $sql = "select * from tbl_restoran";
  13.  
  14. $result = $con->query($sql);
  15. $arr = array();
  16.    
  17. if ($result->num_rows > 0) {
  18.     while($row = $result->fetch_assoc()) {
  19.  
  20. $arr[] = array(
  21. 'id_restoran' => "" . $row["id_restoran"]. "",
  22. 'nama_restoran' => "" . $row["nama_restoran"]. "",
  23. 'url' => "$url_maps" . $row["lat"]. ",".$row["lng"]."");
  24.         }
  25. echo '{ "data":';
  26. echo json_encode($arr, JSON_PRETTY_PRINT);
  27. echo '}';
  28. }
  29. $con->close();
  30.  
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement