Log in to remove this sponsored message
I'm writing a fairly simple webpage that pulls coordinate data from a MySQL DB and creates markers on a Google Map and I was wondering if anyone could help (this is basically the first thing I've done using any web coding at all, and I started yesterday).
So far, I've got the connection to the DB and I'm pulling out the right data out of each record. Then I'm echoing said data from a php block into JS statements, trying to call a createMarker function, but the JS code isn't being run even though I can see it all written fine in the source. I'll post the code from the start of the php, so it doesn't include the createMarker function or the map setup etc.
| php code |
<?php
$link = mysql_connect("mysql", "12669_events", "events") or die(mysql_error());;
mysql_select_db("12669_events") or die(mysql_error());
$data = mysql_query("SELECT * FROM event",$link);
if(!$data){
echo "no results";
}
$info = mysql_fetch_array( $data );
$num=mysql_numrows($data);?>
<script type="text/javascript">
<?
$i=0;
while ($i < $num) {
$name=mysql_result($data,$i,"Name");
$info=mysql_result($data,$i,"Info");
$lat=mysql_result($data,$i,"Lat");
$long=mysql_result($data,$i,"Long");
echo "var point = new GLatLng(" . $lat . "," . $long . ");\n";
echo "var marker = createMarker(point," . $name . ");\n";
echo "map.addOverlay(marker);\n";
echo "\n";
$i++;
}
mysql_close($link);
?>
</script>
|
Any help would be much appreciated. If you need to know anything else, or see where I'm hosting this just ask.
Thanks.