beermaker74 Posted January 30, 2007 Share Posted January 30, 2007 I have this script that I am playing with to create an xml file from a mysql query[code=php:0]<?php $file= fopen("results.xml", "w"); $xml_output = "<?xml version=\"1.0\"?>\n";$xml_output .= "<gallery>\n";for($x = 0 ; $x < mysql_num_rows($Recordset1) ; $x++){ $totalRows_Recordset1 = mysql_fetch_assoc($Recordset1); $xml_output .= "\t<listings>\n"; $xml_output .= "\t\t<houseid>" . $totalRows_Recordset1['houseid'] . "</houseid>\n"; $xml_output .= "\t\t<username>" . $totalRows_Recordset1['username'] . "</username>\n"; $xml_output .= "\t\t<address>" . $totalRows_Recordset1['address'] . "</address>\n"; $xml_output .= "\t</listings>\n";}$xml_output .= "</gallery>"; fwrite($file, $xml_output); fclose($file); echo "XML has been written. <a href=\"results.xml\">View the XML.</a>";?> [/code]here is the result of a query with one record<gallery><listings><houseid/><username/><address/></listings></gallery>the result is not listed. Here is the result of a query with 2 records<gallery><listings><houseid>26</houseid><username>jerry</username><address>55 fake ave</address></listings><listings><houseid/><username/><address/></listings></gallery>there is 2 records in that query. For some reason it is only outputing anything over 1 record. yet it is displaying blank tagsif you see my problem please let me know. I am just trying to write from a simple query now. MY real task is to write the xml from a more advanced query. So I need to figure out the simple problem firstthanks Quote Link to comment Share on other sites More sharing options...
sasa Posted January 30, 2007 Share Posted January 30, 2007 if you have line mysql_fetch_assoc($Recordset1); before for loop temowe it 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.