hello everyone
im new to php and mysql i been trying to export mysql data in an xml file my code below i have problem picking data in the database to display in the xml file, the xml file only show the field in the datbase any help please thank
---------------------------
code
$result = MYSQL_QUERY("SE LECT * from user " );
// create a new XML document
$doc = new DomDocument('1. 0');
// create root node
$root = $doc->createElement( 'root');
$root = $doc->appendChild($r oot);
// process one row at a time
while($row = mysql_fetch_ass oc($result)) {
// add node for each row
$occ = $doc->createElement( $dbproduct);
$occ = $root->appendChild($o cc);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$child = $doc->createElement( $fieldname);
$child = $occ->appendChild($c hild);
$child = $doc->createElement( $fieldname);
$child = $occ->appendChild($c hild);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->saveXML();
//echo $xml_string;
$doc->save('test.xml ');
---------------------------------------------------
xml file
<?xml version='1.0
<root>
<user>
<id></id>
<name>/name<>
</user>
</root>
im new to php and mysql i been trying to export mysql data in an xml file my code below i have problem picking data in the database to display in the xml file, the xml file only show the field in the datbase any help please thank
---------------------------
code
$result = MYSQL_QUERY("SE LECT * from user " );
// create a new XML document
$doc = new DomDocument('1. 0');
// create root node
$root = $doc->createElement( 'root');
$root = $doc->appendChild($r oot);
// process one row at a time
while($row = mysql_fetch_ass oc($result)) {
// add node for each row
$occ = $doc->createElement( $dbproduct);
$occ = $root->appendChild($o cc);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$child = $doc->createElement( $fieldname);
$child = $occ->appendChild($c hild);
$child = $doc->createElement( $fieldname);
$child = $occ->appendChild($c hild);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->saveXML();
//echo $xml_string;
$doc->save('test.xml ');
---------------------------------------------------
xml file
<?xml version='1.0
<root>
<user>
<id></id>
<name>/name<>
</user>
</root>
Comment