I have a database of latitudes and longitudes. I am using java script and Google Maps API to generate a heatmap of this information. I am trying to populate the javascript array using PHP. Currently, I am doing this:
alumdata = [ $.ajax({
url: 'Major.php',
type: 'POST'
data: { major : major },
success: function (data) {
}
})
];
Major.php is the PHP file that will populate the Javascript array, alumdata. I am basically trying to add Google maps objects into every element of the JS Array and calling the initalize function so that the locations on the heatmap change according to the value of the variable major. In my Major.php file, I do this:
<?php
require 'connectDB.php';
$major = $_POST['major'];
if ($major == 'All'){
if(!$entry=$db->query("SELECT * FROM trial"))
die('There was an error connecting: queryError [' . $db->error . ']');
}
else{
if(!$entry=$db->query("SELECT * FROM trial WHERE Major = '$major'"))
die('There was an error connecting: queryError [' . $db->error . ']');
}
while($foobar=$entry->fetch_assoc()){
$longitude = $foobar['Longitude'];
$latitude = $foobar['Latitude'];
print <<<HTML2
new google.maps.LatLng($latitude, $longitude),
HTML2;
}
?>
However, nothing is displayed. I have been messing around with this for a while and cannot find a solution. I would appreciate any suggestions. Thank you.