Writing MYSQL data into an XML file using PHP Code.
Posted: Thu Jun 24, 2004 3:59 pm
Hello,
I am a newbie to PHP code.
I have a mysql database and I am able to output the information into a dynamic table. What I would like to do is also creat an XML file using the same data from the mysql database.
Here is the part of the code that I am using to attempt to create and write to an XML file.
<?php
$xmldec = '<?xml version="1.0" encoding="iso-8859-1"?>';
touch("news.xml");
$fp = fopen("news.xml", "w");
fwrite ($fp, "$xmldec \n");
$counter = 1;
while ($counter <= $totalRows_news_records){
fwrite ($fp, "<news>\n");
fwrite ($fp, $row_news_records['id']);
fwrite ($fp, "</news>\n");
$counter++;
}
?>
The XML file gets created, and it writes the xml declaraction and the "news" tags as well. However, the records are not ouputted.
Does anyone have any suggestions?
Thanks.
I am a newbie to PHP code.
I have a mysql database and I am able to output the information into a dynamic table. What I would like to do is also creat an XML file using the same data from the mysql database.
Here is the part of the code that I am using to attempt to create and write to an XML file.
<?php
$xmldec = '<?xml version="1.0" encoding="iso-8859-1"?>';
touch("news.xml");
$fp = fopen("news.xml", "w");
fwrite ($fp, "$xmldec \n");
$counter = 1;
while ($counter <= $totalRows_news_records){
fwrite ($fp, "<news>\n");
fwrite ($fp, $row_news_records['id']);
fwrite ($fp, "</news>\n");
$counter++;
}
?>
The XML file gets created, and it writes the xml declaraction and the "news" tags as well. However, the records are not ouputted.
Does anyone have any suggestions?
Thanks.