Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>US Cities Database</title>
  5. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  6. <link rel="stylesheet" href="index.css" type="text/css" />
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  8. </head>
  9.  
  10. <script>
  11.  
  12. function doWhenReady () {
  13. $('a').click(showMap);
  14. };
  15.  
  16. function showMap(event) {
  17. var element = $(event.currentTarget);
  18. var lat = element.attr('lat');
  19. var long = element.attr('long');
  20. var url = "https://maps.google.com/maps?q="+lat+","+long+"&h1=es&z=12&t=m&output=embed";
  21. $('iframe').attr('src', url);
  22. }
  23.  
  24. $(document).ready(doWhenReady);
  25.  
  26. </script>
  27.  
  28. <body class="container">
  29.  
  30. <h4>US Cities Zip Code and Latitude / Longitude Locator</h4>
  31. <p><strong>Make sure to enter the smaller Zip Code in the first box, and the larger Zip Code in the second box.</strong></p>
  32. <form action="index.php" method="POST" class="form-inline">
  33. <div class="form-group">
  34. <label for="city">City</label>
  35. <input type="text" class="form-control" name="city" />
  36. </div>
  37. <div class="form-group">
  38. <label for="state">State</label>
  39. <input type="text" class="form-control" name="state" />
  40. </div>
  41. <div class="form-group">
  42. <label for="zipFrom">Zipcode from:</label>
  43. <input type="text" class="form-control" name="zipFrom" />
  44. </div>
  45. <div class="form-group">
  46. <label for="zipTo">to:</label>
  47. <input type="text" class="form-control" name="zipTo" />
  48. </div>
  49. <button type="submit" class="btn btn-default btn-primary">Search</button>
  50.  
  51. </form>
  52. <hr>
  53.  
  54. <div class="row">
  55. <div class="col-md-5 scrollable">
  56. <div class="search-results">
  57. <h4>Search results:</h4>
  58.  
  59. <?php
  60.  
  61. $host = 'localhost';
  62. $username = 'caleyhalpern';
  63. $password = '';
  64. $dbName = 'project224';
  65.  
  66. $db = mysqli_connect ($host, $username, $password, $dbName);
  67. if (!$db) {
  68. die("Failed to connect to MySQL: (" . mysqli_connect_errno() . ") " . $mysqli->connect_error);
  69. }
  70.  
  71. $searchCity = $_POST['city'];
  72. $searchState = $_POST['state'];
  73. $searchZipCode = $_POST['zipcode'];
  74. if ((isset($searchCity) || isset($searchState)) && (($searchCity != '') || ($searchState != '')))
  75. $query = 'SELECT * FROM zips WHERE city LIKE "%'.$searchCity.'%" AND state LIKE "%'.$searchState.'%"';
  76. $results = mysqli_query($db, $query);
  77. $resultArray = mysqli_fetch_all($results, MYSQLI_ASSOC);
  78. ?>
  79.  
  80. <table class="table table-striped table-condensed small">
  81. <thead>
  82. <tr>
  83. <th>Show</th>
  84. <th>Zip</th>
  85. <th>State</th>
  86. <th>City</th>
  87. <th>Lat</th>
  88. <th>Long</th>
  89. </tr>
  90. </thead>
  91.  
  92. <tbody>
  93. <?php
  94. foreach($resultArray as $city) {
  95. echo "<tr>";
  96. echo '<td><a href="#" lat="'.$city['lat'].'" long="'.$city['lng'].'">Show</a></td>';
  97. echo "<td>".$city['zip']."</td>";
  98. echo "<td>".$city['state']."</td>";
  99. echo "<td>".$city['city']."</td>";
  100. echo "<td>".$city['lat']."</td>";
  101. echo "<td>".$city['lng']."</td>";
  102. echo "</tr>";
  103. }
  104. ?>
  105. </tbody>
  106. </table>
  107. <?php
  108. }
  109. ?>
  110. </div>
  111. </div>
  112. <div class="col-md-7">
  113. <div class="map">
  114. <h4>Map:</h4>
  115.  
  116. <iframe src=""></iframe>
  117. </div>
  118. </div>
  119. </div>
  120.  
  121. </body>
  122.  
  123. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement