Generating XML from PHP
Posted: Tue Nov 12, 2002 11:49 pm
I am trying to generate an XML document using PHP pulling down a table from a MySQL database - though there has to be something I'm missing - what I'm doing now is something like this...
I know there is some sort of mysql xml dump function out there, but I'm looking to generate it in the way I've specified above if at all possible.. any input would be much appreciated!
And if my question screams idiocy, I'm sorry!!
Code: Select all
<?php
echo "<?xml version='1.0' encoding='ISO-8859-1' ?>";
echo "<list>";
$result = mysql_query("SELECT * FROM table ORDER BY ID DESC");
while($i=mysql_fetch_array($result))
{
$ID = $iї"ID"];
$firstname = $iї"firstname"];
$lastname = $iї"lastname"];
echo "<person>";
echo "<ID>$ID</ID>";
echo "<firstname>$firstname</firstname>";
echo "<lastname>$lastname</lastname>";
echo "</person>";
}
echo "</list>";
?>And if my question screams idiocy, I'm sorry!!