Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. $app->get('/markers/?', function () use ($app) {
  2. $controller = new UFMarkersController($app);
  3. return $controller->getMarkersJSON();
  4. });
  5.  
  6. <!DOCTYPE html>
  7. <html lang="en">
  8. <head>
  9. {% include 'components/head.html' %}
  10. </head>
  11. <body>
  12. <?php
  13. include('DB_INFO.php');
  14.  
  15. function getMarkersJSON(){
  16. // Opens a connection to a MySQL server.
  17. $connection = mysqli_connect($server, $username, $password);
  18.  
  19. if (!$connection) {
  20. die('Not connected : ' . mysqli_error());}
  21. // Sets the active MySQL database.
  22. $db_selected = mysqli_select_db($database, $connection);
  23.  
  24. if (!$db_selected) {
  25. die('Can't use db : ' . mysqli_error());}
  26.  
  27. // Selects all the rows in the markers table.
  28. $query = "SELECT * FROM tester WHERE 1";
  29. $result = mysqli_query($connection, $query);
  30.  
  31. if (!$result) {
  32. die('Invalid query: '. mysqli_error());
  33. }
  34. $markers = array();
  35. while ($row = mysqli_fetch_assoc($result)) {
  36. //Assuming "lat" is column name in tester table. Please change it if required.
  37. $lat= $rows['lat'];
  38. //Assuming "lng" is column name in tester table. Please change it if required.
  39. $lng= $rows['lng'];
  40. $markers = array('lat' => $lat, 'lng' => $lng);
  41. }
  42. echo json_encode($markers);
  43. }
  44. ?>
  45. </body>
  46. </html>
  47.  
  48. <meta http-equiv="Content-Type" content="text/html;charset=[your-charset]" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement