Forum Moderators: coopster

Message Too Old, No Replies

xml file from php - filename from query

         

j milo taylor

12:07 pm on Jun 16, 2008 (gmt 0)

10+ Year Member



i need to autogenerate xml files from querying a database., the name of these files are created acoording to the query criteria. i had this working, but something has fallen over. here's an edited down version of the code:

SELECT...
FROM..
WHERE..

ORDER by location_work", $colname_rs_year);
$rs_year = mysql_query($query_rs_year, $immapp) or die(mysql_error());
$row_rs_year = mysql_fetch_assoc($rs_year);
$totalRows_rs_year = mysql_num_rows($rs_year);

<!-- lines above select return rows. Lines below output xml --!>

$xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?> <?xml-stylesheet type=\"text/xsl\" href=\"X3D-XSLT_Work_Year.xsl\"?>\n";
$xml_output .= "<works>\n";

for($x = 0 ; $x < mysql_num_rows($rs_year) ; $x++){
$row_rs_year = mysql_fetch_assoc($rs_year);
$xml_output .= "\t<work>\n";
$xml_output .= "\t\t<Work_Year>" . $row_rs_year['year_work'] . "</Work_Year>\n";
$xml_output .= "\t\t<Work_ID>" . $row_rs_year['id_work'] . "</Work_ID>\n";
$xml_output .= "\t\t<Work_Image>" . $row_rs_year['image_image'] . "</Work_Image>\n";
$xml_output .= "\t\t<Artist_Second_Name>" . $row_rs_year['2ndname_artist'] . "</Artist_Second_Name>\n";
$xml_output .= "\t\t<Work_Name>" . $row_rs_year['name_work'] . "</Work_Name>\n";
$xml_output .= "\t\t<Work_Type>" . $row_rs_year['worktype_work'] . "</Work_Type>\n";

$xml_output .= "\t</work>\n ";
}

$xml_output .= "</works>\n";

$filename = 'XML-WORK_YEAR-' . $row_rs_year['year_work'] . '.xml';

<!-- this line above is where i think i have a problem. what happens now is the file is made XML-WORK_YEAR-.xml, and the string is not recognised. I need XML-WORK_YEAR-1978.xml, XML-WORK_YEAR-1986.xml, XML-WORK_YEAR-1994.xml etc --!>

i can't figure it out
Any ideas?
Many thanks
Milo

coopster

12:31 pm on Jun 25, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you run the query from the command line or dumped the raw output to see if the [fixed]year_work/fixed] column is populated for the rows returned in your result set? Looks like it is NULL or something.