Advertisement
sagytt

Untitled

Aug 22nd, 2017
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2.  
  3. // php populate html table from mysql database
  4.  
  5. $hostname = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $databaseName = "detailsdb";
  9.  
  10. // connect to mysql
  11. $connect = mysqli_connect($hostname, $username, $password, $databaseName);
  12.  
  13. // mysql select query
  14.  
  15. $query = "SELECT * FROM details ORDER BY Id DESC LIMIT 1";
  16.  
  17.  
  18. // result for method one
  19. $result1 = mysqli_query($connect, $query);
  20.  
  21.  
  22. // result for method two
  23. $result2 = mysqli_query($connect, $query);
  24.  
  25. $query3="SELECT Latitude ,Longitude FROM details ";
  26.  
  27. $result3=mysqli_query($connect, $query3);
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. <!DOCTYPE html>
  35. <html>
  36. <head>
  37.  
  38. <title>Hello User</title>
  39. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDyXdL4cZlxo3ldIuvi6_HpZa2jhj7iOU0&callback=initMap"
  40. async defer></script>
  41. <style>#mapcanvas { height: 600px; width: 1500px}</style>
  42. <script>
  43.  
  44.  
  45.  
  46. function loadmap() {
  47. <?php while( $row3 = mysqli_fetch_array($result3)):;?>
  48. var x=<?php echo $row3[0];?>;
  49. var y=<?php echo $row3[1];?>;
  50. <?php endwhile;?>
  51. var uluru = {lat: x, lng: y};
  52. var map = new google.maps.Map(document.getElementById('mapcanvas'), {zoom: 18,center: uluru });
  53.  
  54. var marker = new google.maps.Marker({position: uluru,map: map})
  55.  
  56. setInterval(loadmap,3000);
  57. }
  58.  
  59.  
  60.  
  61.  
  62. </script>
  63.  
  64. </head>
  65. <body onload="loadmap()">
  66. <h1>Tracking Program</h1>
  67.  
  68. <div id="mapcanvas"></div>
  69.  
  70. <table style="background-color: red;">
  71.  
  72. <tr>
  73.  
  74. <th>First Name</th>
  75. <th>Last Name</th>
  76. <th>Id</th>
  77. <th>Phone Number</th>
  78. <th>Address</th>
  79. <th>Latitude</th>
  80. <th>Longitude</th>
  81. </tr>
  82.  
  83. <?php $row1 = mysqli_fetch_array($result1);?>
  84.  
  85. <tr>
  86. <td><?php echo $row1[0];?></td>
  87. <td><?php echo $row1[1];?></td>
  88. <td><?php echo $row1[2];?></td>
  89. <td><?php echo $row1[3];?></td>
  90. <td><?php echo $row1[4];?></td>
  91. <td><?php echo $row1[5];?></td>
  92. <td><?php echo $row1[6];?></td>
  93.  
  94. </tr>
  95.  
  96. </table>
  97.  
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement