phpretard Posted January 23, 2008 Share Posted January 23, 2008 I am echoing some javascript just fine but I need 1 part of the script to echo 1 then 2 then 3 and so on. while($row = mysql_fetch_array($result)) { echo" var marker1= new GMarker(new GLatLng($lon,$lat), markerOptions); map.addOverlay(marker1); GEvent.addListener(marker1, 'click', function() { marker1.openInfoWindowHtml(WINDOW_HTML1);}); "; } The only change I need is marker1 and then marker2 ... according to the number of rows in the database. (there are 2 instances of "marker1") Could you help? -Anthony Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/ Share on other sites More sharing options...
foreverhex Posted January 23, 2008 Share Posted January 23, 2008 I'll take a shot in the dark. Im not good with php/java/ajax mix, but what it seems like is you need your loop to increase the marker number. So something like while($row = mysql_fetch_array($result)) { echo" var marker" . $num . "= new GMarker(new GLatLng($lon,$lat), markerOptions); map.addOverlay(marker" . $num . '); GEvent.addListener(marker" . $num . ", 'click', function() { marker" . $num . ".openInfoWindowHtml(WINDOW_HTML" . $num . ");}); "; $num++ } Sorry if this seems stupid. I figured I would help as much as possible. Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-446985 Share on other sites More sharing options...
phpretard Posted January 23, 2008 Author Share Posted January 23, 2008 Thank you very much!! Maybe you do know...and you didn't that you knew. Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-446989 Share on other sites More sharing options...
phpretard Posted January 24, 2008 Author Share Posted January 24, 2008 I thought it worked but it didn't. Can you take another shot? Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-447685 Share on other sites More sharing options...
foreverhex Posted February 1, 2008 Share Posted February 1, 2008 Sorry I haven't been on. If you are still having a problem you can try this: I noticed that $num isn't set so. simply put $num = '1'; above the code I gave you. Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-455268 Share on other sites More sharing options...
Dada78 Posted February 1, 2008 Share Posted February 1, 2008 Google has a code for outputting with php from MySQL, that is what you need. I have done that on this page. http://www.mesquitechristmas.com/local/map.php The addresses in the DB are geocoded to lat/long and stored in the DB with a simple PHP code then outputted to Js via XML. Just go look at the google map docs for Google Maps with PHP/MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-455275 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.