leest Posted April 25, 2008 Share Posted April 25, 2008 Ok, I have a piece of code i have modified to take results from a database and plot them on to a google map, now the code works well, however it only display one result and doesn't seem to loopthrough the xml code, i am quite new with this type of coding and so a litle confused any pointers would be much appreciated. $sql = "SELECT * FROM joborder "; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $title = $row['title']; $city = $row['city']; $state = $row['state']; } {"locations": {"location":[ {"id": " echo "$title"; ", "city": " echo "$title"; ", "location": " echo "$city"; ", "address": " echo "$state"; ", "date": "May 2nd, 2007" } ] }} Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/ Share on other sites More sharing options...
fenway Posted April 25, 2008 Share Posted April 25, 2008 It's hard to see w/o proper indentation... btw, there's a UDF that does this for you. Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/#findComment-527335 Share on other sites More sharing options...
leest Posted April 25, 2008 Author Share Posted April 25, 2008 Ok, well i guess that could be a whole lot easier, any idea where i would find it??? Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/#findComment-527337 Share on other sites More sharing options...
GingerRobot Posted April 25, 2008 Share Posted April 25, 2008 You close your while loop after setting the variables $title,$city and $state, but before doing anything with them - hence why it doesn't loop in the way you would want. I expect fenway was referring to: http://code.google.com/apis/maps/ Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/#findComment-527346 Share on other sites More sharing options...
leest Posted April 25, 2008 Author Share Posted April 25, 2008 Cheers, that works, i guess i will go have a look for the udf, cheers guys. Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/#findComment-527363 Share on other sites More sharing options...
fenway Posted April 26, 2008 Share Posted April 26, 2008 Cheers, that works, i guess i will go have a look for the udf, cheers guys. mysqludf.com Link to comment https://forums.phpfreaks.com/topic/102936-solved-mysql-result-and-xml/#findComment-527695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.