Guten Tag,
warum funzt folgendes kleines Script nicht ? Es gibt zwar den Tabelleninhalt aus aber es wird nix formatiert oder so.
<?php
// retrieve data from DB
if (!$dbconnect = mysql_connect('localhost', 'test', 'test')) {
echo "Connection failed to the host 'localhost'.";
exit;
} // if
if (!mysql_select_db('test')) {
echo "Cannot connect to database 'test'";
exit;
} // if
$table_id = 'bestellinfo';
$query = "SELECT * FROM ".$table_id;
$dbresult = mysql_query($query, $dbconnect);
// create a new XML document
$doc = domxml_new_doc('1.0');
// create root node
$root = $doc->create_element('test');
$root = $doc->append_child($root);
// process each row from the sql query
while ($row = mysql_fetch_assoc($dbresult)) {
// add node for each row
$occ = $doc->create_element($table_id);
$occ = $root->append_child($occ);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$child = $doc->create_element($fieldname);
$child = $occ->append_child($child);
$value = $doc->create_text_node($fieldvalue);
$value = $child->append_child($value);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->dump_mem(true);
echo $xml_string;
?>