Jump to content

[How] DB entires, when button pressed go into search bar.


Lee-Bartlett

Recommended Posts

Ok i have google map on my site, not sure if i can link to it, if i get told i can i will if not i wont. Ok i have a long + lat collum, but instead user putting it in search bar below, id like it to automaticaly search the map below with them 2 db entries.

 

Code so far,

 

<?php  require_once("includes/db_connection.php"); ?>


<?php

$sql = "SELECT * from tblbasicform";
$res = mysql_query($sql) or die(mysql_error());

echo "<table border=2>";
echo "<tr> <td>Name</td><td>Email</td><td>Buissnes Name</td><td>Location</td><td>Latitude</td><td>Longitude</td> <td>Free or Paid</td></tr>";
while($row = MYSQL_FETCH_ARRAY($res))
{

echo "<tr><td>".$row['name']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['buissnes_name']."</td>";
echo "<td>".$row['location']."</td>";
echo "<td>".$row['latitude']."</td>";
echo "<td>".$row['longitude']."</td>";
echo "<td>".$row['type']."</tr>";
}
echo "</table><br>";
?><a href="userform.php">Submit a WIFI hotspot</a>
<br />
<br />
Wanna find your destination, simple enter the latitude and longitude from the entries below.







   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
      	<title>Find out your location with geographic coordinates (lat/long) with Google Maps API</title>
      <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAgnVrcDn5i-V_BsqvXy3j8RRle8Rt1EK93-n5qGMjk9aCuGqlpBQ2sCqItCc79KzQksp90dVmLGk45w"
      type="text/javascript"></script>
    <script type="text/javascript">
    

        

function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var center = new GLatLng(51.50015,  -0.12624	);
        map.setCenter(center, 15);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: true});  
        map.addOverlay(marker);
        document.getElementById("lat").innerHTML = center.lat().toFixed(5);
        document.getElementById("lng").innerHTML = center.lng().toFixed(5);

  GEvent.addListener(marker, "dragend", function() {
       var point = marker.getPoint();
      map.panTo(point);
       document.getElementById("lat").innerHTML = point.lat().toFixed(5);
       document.getElementById("lng").innerHTML = point.lng().toFixed(5);

        });


 GEvent.addListener(map, "moveend", function() {
	  map.clearOverlays();
    var center = map.getCenter();
	  var marker = new GMarker(center, {draggable: true});
	  map.addOverlay(marker);
	  document.getElementById("lat").innerHTML = center.lat().toFixed(5);
   document.getElementById("lng").innerHTML = center.lng().toFixed(5);


 GEvent.addListener(marker, "dragend", function() {
      var point =marker.getPoint();
     map.panTo(point);
      document.getElementById("lat").innerHTML = point.lat().toFixed(5);
     document.getElementById("lng").innerHTML = point.lng().toFixed(5);

        });

        });

      }
    }

   function showAddress(address) {
   var map = new GMap2(document.getElementById("map"));
       map.addControl(new GSmallMapControl());
       map.addControl(new GMapTypeControl());
       if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
	  document.getElementById("lat").innerHTML = point.lat().toFixed(5);
   document.getElementById("lng").innerHTML = point.lng().toFixed(5);
	 map.clearOverlays()
		map.setCenter(point, 14);
   var marker = new GMarker(point, {draggable: true});  
	 map.addOverlay(marker);

	GEvent.addListener(marker, "dragend", function() {
      var pt = marker.getPoint();
     map.panTo(pt);
      document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
     document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
        });


 GEvent.addListener(map, "moveend", function() {
	  map.clearOverlays();
    var center = map.getCenter();
	  var marker = new GMarker(center, {draggable: true});
	  map.addOverlay(marker);
	  document.getElementById("lat").innerHTML = center.lat().toFixed(5);
   document.getElementById("lng").innerHTML = center.lng().toFixed(5);

 GEvent.addListener(marker, "dragend", function() {
     var pt = marker.getPoint();
    map.panTo(pt);
    document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
   document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
        });

        });

            }
          }
        );
      }
    }
    </script>
  </head>

  
<body onload="load()" onunload="GUnload()" >

  <form action="#" onsubmit="showAddress(this.address.value); return false">
     <p>        
      <input type="text" size="50" name="address" value="Henderson Nevada USA" />
      <input type="submit" value="Search!" />
      </p>
    </form>

<p align="left">


<table  bgcolor="" width="333">
  <tr>
    <td width="60" align="center"><font color="#0000FF"><b>Latitude:</b></font></td>
    <td id="lat" width="90" align="center">
    <p align="left"></td>

    <td width="72" align="center"><font color="#0000FF"><b>Longitude:</b></font></td>
    <td id="lng" width="90" align="center">
    <p align="left"></td>

  </tr>
</table>
</p>
  <p>
  <div align="center" id="map" style="width: 1000px; height: 700px"><br/></div>
   </p>
  </div>
  </body>

</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.