Advertisement
sagytt

Untitled

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