Jeff L Posted September 17, 2009 Share Posted September 17, 2009 Hi all, I have just started learning how to use PHP and I have been developing a website that allows users to query rock climbing routes at different locations. I have embedded a google map and then query a database which then adds markers to a page. I have been reading a book recently entitled Beginning Google Maps Applications with PHP and Ajax which has been quite good but I am stuck on a piece of code. This code which is below is supposed to query a database and add markers to a map. Can someone please explain the syntax that is used in the 'var markers' section of the code as I can't get it to work. <?php // Connect to the database require($_SERVER['DOCUMENT_ROOT'] . '/Cragview/db_login.php'); $conn = mysql_connect($db_host, $db_username, $db_password); mysql_select_db("cragview", $conn); $north = 20.421865; $south = 18.281518; $west = -156.123962; $east = -150; $query = "SELECT * FROM fcc_location WHERE longitude < $east AND latitude < $north AND longitude > $west AND latitude > $south"; $result = mysql_query($query, $conn); $joiner = ''; $count = 0; ?> var markers = [ <?php while($row = mysql_fetch_assoc($result)): ?> <?= $joiner ?> { 'latitude': <?= $row['latitude'] ?>, 'longitude': <?= $row['longitude'] ?>, 'address': '<?= addslashes($row['struc_address']) ?>', 'city': '<?= addslashes($row['struc_city']) ?>', 'state': '<?= addslashes($row['struc_state']) ?>', 'height': '<?= addslashes($row['struc_height']) ?>', 'elevation': '<?= addslashes($row['struc_elevation']) ?>', 'type': '<?= addslashes($row['struc_type']) ?>', 'owner': '<?= addslashes($row['owner_name']) ?>' } <? $joiner = ','; $count++; ?> <?php endwhile; ?> ]; Any assistance you can give me would be most appreciated. Regards Jeff Lean Brisbane, Australia Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.