Guest User

Untitled

a guest
Apr 15th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. <?php
  2. require("dbinfotanah.php");
  3.  
  4. function parseToXML($htmlStr)
  5. {
  6. $xmlStr=str_replace('<','<',$htmlStr);
  7. $xmlStr=str_replace('>','>',$xmlStr);
  8. $xmlStr=str_replace('"','"',$xmlStr);
  9. $xmlStr=str_replace("'",'&#39;',$xmlStr);
  10. $xmlStr=str_replace("&",'&',$xmlStr);
  11. return $xmlStr;
  12. }
  13.  
  14. // Opens a connection to a MySQL server
  15. $connection=mysqli_connect ('localhost', $username, $password, $database);
  16. if (!$connection) {
  17. die('Not connected : ' . mysqli_error());
  18. }
  19.  
  20. // Set the active MySQL database
  21. $db_selected = mysqli_select_db($connection , $database);
  22. if (!$db_selected) {
  23. die ('Can't use db : ' . mysqli_connect_error());
  24. }
  25.  
  26. // Select all the rows in the markers table
  27. $query = "SELECT * FROM table7 WHERE 1";
  28. $result = mysqli_query($connection , $query);
  29. if (!$result) {
  30. die('Invalid query: ' . mysqli_connect_error());
  31. }
  32.  
  33. header("Content-type: text/xml");
  34.  
  35. // Start XML file, echo parent node
  36. echo '<table_p>';
  37.  
  38. // Iterate through the rows, printing XML nodes for each
  39. while ($row = @mysqli_fetch_assoc($result)){
  40. // Add to XML document node
  41. echo '<project ';
  42. echo 'Project="' . parseToXML($row['Project']) . '" ';
  43. echo 'Project2="' . parseToXML($row['Project2']) . '" ';
  44. echo 'Scope="' . $row['Scope'] . '" ';
  45. echo 'Area="' . $row['Area'] . '" ';
  46. echo 'Position="' . $row['Position'] . '" ';
  47. echo 'Company="' . $row['Company'] . '" ';
  48. echo 'Years="' . $row['Years'] . '" ';
  49. echo 'lat="' . $row['Lat'] . '" ';
  50. echo 'long="' . $row['Long'] . '" ';
  51. echo '/>';
  52. }
  53.  
  54. // End XML file
  55. echo '</table_p>';
  56.  
  57. ?>
  58.  
  59. <?php
  60. $username="root";
  61. $password="";
  62. $database="dbtanah";
  63. ?>
  64.  
  65. <script>
  66.  
  67. function initMap() {
  68. var map = new google.maps.Map(document.getElementById('map'), {
  69. center: new google.maps.LatLng(-1.3327011, 114.5706969),
  70. zoom: 5
  71. });
  72. var infoWindow = new google.maps.InfoWindow;
  73.  
  74. // Change this depending on the name of your PHP or XML file
  75. downloadUrl('dbexporttanah.php', function(data) {
  76. var xml = data.responseXML;
  77. var markers = xml.documentElement.getElementsByTagName('project');
  78. Array.prototype.forEach.call(markers, function(markerElem) {
  79. var Project = markerElem.getAttribute('Project');
  80. var Project2 = markerElem.getAttribute('Project2');
  81. var Scope = markerElem.getAttribute('Scope');
  82. var Area = markerElem.getAttribute('Area');
  83. var Position = markerElem.getAttribute('Position');
  84. var Company = markerElem.getAttribute('Company');
  85. var Years = markerElem.getAttribute('Years');
  86. var point = new google.maps.LatLng(
  87. parseFloat(markerElem.getAttribute('lat')),
  88. parseFloat(markerElem.getAttribute('long')));
  89.  
  90. var infowincontent = document.createElement('div');
  91.  
  92.  
  93. var strong = document.createElement('strong');
  94. strong.textContent = Project
  95. infowincontent.appendChild(strong);
  96. infowincontent.appendChild(document.createElement('br'));
  97.  
  98. var strong = document.createElement('strong');
  99. strong.textContent = Project2
  100. infowincontent.appendChild(strong);
  101. infowincontent.appendChild(document.createElement('br'));
  102.  
  103. var text = document.createElement('text');
  104. text.textContent = Area
  105. infowincontent.appendChild(text);
  106. infowincontent.appendChild(document.createElement('br'));
  107.  
  108. var marker = new google.maps.Marker({
  109. map: map,
  110. position: point
  111.  
  112. });
  113. marker.addListener('click', function() {
  114. infoWindow.setContent(infowincontent);
  115. infoWindow.open(map, marker);
  116. });
  117. });
  118. });
  119. }
  120.  
  121.  
  122.  
  123. function downloadUrl(url, callback) {
  124. var request = window.ActiveXObject ?
  125. new ActiveXObject('Microsoft.XMLHTTP') :
  126. new XMLHttpRequest;
  127.  
  128. request.onreadystatechange = function() {
  129. if (request.readyState == 4) {
  130. request.onreadystatechange = doNothing;
  131. callback(request, request.status);
  132. }
  133. };
  134.  
  135. request.open('GET', url, true);
  136. request.send(null);
  137. }
  138.  
  139. function doNothing() {}
  140. </script>
Add Comment
Please, Sign In to add comment