So my first post on stack overflow, I have 2 PHP arrays that contains latitude and longitude. The values that these variables store depends on what the user searches for.
I have a simple map that i got from the google maps api tutorial, How can i add multiple markers to the map using only latitude and longitude from php arrays?
I am very grateful for any kind response to this
<head>
<link type="text/css" rel="stylesheet" href="searchnext.css"/>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(57.708742,11.820850),
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
<?php
include_once'config/connect.php';
$search= $_POST['search'];
// To protect MySQL injection (more detail about MySQL injection)
$search = stripslashes($search);
$search = mysql_real_escape_string($search);
$sql= "select * from venue where vID in (select vID from sv where sID in (select sID from sports where sN = '$search'));";
$result=mysql_query($sql);
$latitude = array();
$longitude = array();
while( $row1 = mysql_fetch_array($result)){
array_push($latitude, $row1['latitude']);
}
while( $row2 = mysql_fetch_array($result)){
array_push($longitude, $row2['longitude']);
}
echo $latitude[1];
echo $latitude[2];
echo $latitude[3];
?>
</body>