Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. </head>
  6. <body>
  7. <?php
  8. $servername = "localhost";
  9. $username = "username";
  10. $password = "password";
  11. mysql_connect($servername, $username, $password) or die(mysql_error());
  12. mysql_select_db("stuff") or die(mysql_error());
  13. $result = mysql_query("SELECT Location, Latitude, Longitude FROM Places WHERE Latitude IS NOT NULL GROUP BY Location, Latitude, Longitude");
  14. $places = array();
  15. while (($row = mysql_fetch_array($result, MYSQL_NUM)) !== false) {
  16. $places[] = $row;
  17. }
  18. ?>
  19. <script>
  20. function makeTableHTML(myArray) {
  21. var result = "<table border=1>";
  22. for(var i=0; i<myArray.length; i++) {
  23. result += "<tr>";
  24. for(var j=0; j<myArray[i].length; j++){
  25. result += "<td>"+myArray[i][j]+"</td>";
  26. }
  27. result += "</tr>";
  28. }
  29. result += "</table>";
  30. return result;
  31. }
  32. var places = <?php echo json_encode($places) ?>;
  33. makeTableHTML(places);
  34. </script>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement