display google map with php and mysql using the longitude and latitude stored in the database is not workingg -
i have map page include google map display users static locations using php , mysql because longitude , lattitude stored in database in village table village id in foreign key in user table used inner join problem browser not show anything.
map.php
<!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 name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php print "$firstname $lastname"; ?></title> <link href='http://fonts.googleapis.com/css?family=oswald:400,300' rel='stylesheet' type='text/css' /> <link href='http://fonts.googleapis.com/css?family=abel|satisfy' rel='stylesheet' type='text/css' /> <link href="default.css" rel="stylesheet" type="text/css" media="all" /> <!--[if ie 6]> <link href="default_ie6.css" rel="stylesheet" type="text/css" /> <![endif]--> <script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> </script> <style type="text/css"> #map { width: 850px; height: 500px; border: 0px; padding: 0px; position: absolute; top: 76px; left: 253px; } </style> <script src="http://maps.google.com/maps/api/js?key=aizasyc9ybinmzg9jiwy32fzjwn92iujtjzhjfc&sensor=false" type="text/javascript"></script> <script type="text/javascript"> var icon = new google.maps.markerimage("http://maps.google.com/mapfiles/ms/micons/blue.png", new google.maps.size(32, 32), new google.maps.point(0, 0), new google.maps.point(16, 32)); var center = null; var map = null; var currentpopup; var bounds = new google.maps.latlngbounds(); function addmarker(lat, lng, info) { var pt = new google.maps.latlng(lat, lng); bounds.extend(pt); var marker = new google.maps.marker({ position: pt, icon: icon, map: map }); var popup = new google.maps.infowindow({ content: info, maxwidth: 300 }); google.maps.event.addlistener(marker, "click", function() { if (currentpopup != null) { currentpopup.close(); currentpopup = null; } popup.open(map, marker); currentpopup = popup; }); google.maps.event.addlistener(popup, "closeclick", function() { map.panto(center); currentpopup = null; }); } function initmap() { map = new google.maps.map(document.getelementbyid("map"), { center: new google.maps.latlng(0, 0), zoom: 14, maptypeid: google.maps.maptypeid.roadmap, maptypecontrol: true, maptypecontroloptions: { style: google.maps.maptypecontrolstyle.horizontal_bar }, navigationcontrol: true, navigationcontroloptions: { style: google.maps.navigationcontrolstyle.zoom_pan } }); <?php $query = mysql_query("select lattitude, longitude user u iner join village v on u.village = v.id")or die(mysql_error()); while($row = mysql_fetch_array($query)) { // $name = $row['user_name']; $lat = $row['lattitude']; $lon = $row['longitude']; //$desc = $row['desc']; //'<b>$name</b> echo("addmarker($lat, $lon <br />');\n"); } ?> center = bounds.getcenter(); map.fitbounds(bounds); } </script> </head> <body onload="initmap()" style="margin:0px; border:0px; padding:0px;"> <?php /*require_once('header.php');*/ ?> <div id="wrapper"> <div id="page-wrapper"> <div id="page"> <div id="wide-content"> <div id="map"></div> </div> </div> </div> </div> </div> <?php /*require_once('footer.php');*/ ?> </body> </html>
database stucture
village table:
- id
- village_name
- district_id
- lattitude
- longitude
user table:
- user_id
- first_name
- last_name
- governorate
- district
- village
- birth_date
- email_address
- specialization
- user_name
- password
- interest
- registered_date
- last_log_date
i think problem in query of inner join.
your select query limiting. have selected 2 fields in 2 tables , 2 fields trying join on have been left out of selection. try using select * both tables , rectify typos , go
Comments
Post a Comment