Hello, I am trying to set up a google map to read points from my mysql database. I got it to work but here is the problem. It is a map that show where current airplanes are in the world from my flight simulator, but when my software creates a row it never deletes it. I had a pre-made php code on a different type of map before and it would only read events that are happening now, i think this is the line that it used for reading rows that are going now
$sql = "SELECT * FROM positions WHERE last_update > DATE_SUB( NOW() , INTERVAL 15 MINUTE ) ORDER BY IATA";
But the problem is that my new code is a little different, can someone help me add a similar code to the one before this sentence?
Here is my google map code now:
<html>
<head>
<title>Flights</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAbaFdNtoImpKKOcfBCb_8OBTVV6Nm0EYMs4Nmu9_cYoW7H7T1thRr91VqzOCzWjbL-HO8shohoWA5ow" type="text/javascript"></script>
</head>
<body>
<p><strong>Current Flights</strong></p>
<div id="map" style="width: 800px; height: 500px"></div> <script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(51.512161, -0.14110), 11, G_NORMAL_MAP);
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
<?php
$hostName = "db5.awardspace.com";
/* CHANGE THESE LINE TO YOUR DETAILS */
$userName = "darko886_fsacars";
$password = "my password went here";
$dbName = "darko886_fsacars";
/* make connection to database */
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die("Unable to select database $dbName");
$sql = "SELECT * FROM positions WHERE last_update > DATE_SUB( NOW() , INTERVAL 15 MINUTE ) ORDER BY IATA";
$result = mysql_query( $sql );
$cont = 1;
/* mysql error */
if (!$result) {
print "Error - Database Connection.";
$cont = 0;
}
if ($cont) {
if (mysql_numrows($result) == 0) {
print "No Pilots Actively Flying.";
} else {
print "var point = new GLatLng(" . $row['lat'] . "," . $row['lon'] . ");\n";
print "var marker = createMarker(point, '" . addslashes($row['description']) . "');\n";
print "map.addOverlay(marker);\n";
print "\n";
}
?>
//]]>
</script>
</body>
</html>
And it shows an error
Parse error: syntax error, unexpected $end in /home/www/fsacars.awardspace.com/googlemap.html on line 68
Please help me because this map shows all of the flights that are not current...
Thanks
Darko