Can anybody see why code 1 works but code 2 doesn't? its driving me crazy!!!
CODE 1:
<?PHP
$con=mysqli_connect("a","b","c","d");
$result = mysqli_query($con,"SELECT * FROM map_places");
while($row = mysqli_fetch_array($result))
{
$lat2=$row['latitude'];
$lon2=$row['longitude'];
echo 'var myLatLng = new google.maps.LatLng('.$lat2.','.$lon2.');';
echo 'var myMarker = new google.maps.Marker({';
echo 'position: myLatLng,';
echo 'map: map,';
echo '});';
}
?>
CODE 2:
<?PHP
$con=mysqli_connect("a","b","c","d");
$min = (int)$_POST['min'];
$sql = "
SELECT map_places.latitude, map_places.longitude
FROM map_places
INNER JOIN map_items ON (map_items.host_id = map_places.id)
WHERE map_items.value >".$min."
GROUP BY map_places.id
";
$result1 = mysqli_query($con,$sql);
while($row1 = mysqli_fetch_array($result1));
{
$lat1=$row1['latitude'];
$lon1=$row1['longitude'];
echo 'var myLatLng = new google.maps.LatLng('.$lat1.','.$lon1.');';
echo 'var pokerMarker = new google.maps.Marker({';
echo 'position: myLatLng,';
echo 'map: map,';
echo '});';
}
?>
They are essentially the same code with code 1 pulling all of the data and posting it onto a Google map and code 2 pulling certain data (all that have a value higher than $min) and putting it on a Google map, I have put the select through MySQL and it pulls the correct data, however if I use (int) on $row1... and $row2... the lat long values posted on my map are 0,0. Can anybody explain why this happens? (all code outside what I have posted is the same for code 1 and code 2 and as code 1 works my problem should lie somewhere here). Thank you for any help trying to get code 2 to work has been driving me crazy for days!!
$row1
byprint_r($row1);
.