39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
require_once("config.php");
|
|
//Creates XML string and XML document using the DOM
|
|
$dom = new DomDocument('1.0', 'UTF-8');
|
|
|
|
if (isset($_GET['angebot_id'])) {
|
|
$angebot_id = $_GET['angebot_id'];
|
|
$query = $db->query("
|
|
SELECT * FROM nachfrager
|
|
RIGHT OUTER JOIN anbieter
|
|
ON nachfrager.erfassungs_id=anbieter.erfassungs_id
|
|
WHERE anbieter.angebot_id=$angebot_id
|
|
");
|
|
} else {
|
|
echo "ein problem ist aufgetreten.";
|
|
break;
|
|
}
|
|
//add root == artikel
|
|
$artikel = $dom->appendChild($dom->createElement('artikel'));
|
|
while ($result_array = $query->fetch(PDO::FETCH_ASSOC)) {
|
|
//loop through each key,value pair in row
|
|
foreach($result_array as $key => $value) {
|
|
//$key holds the table column name
|
|
|
|
|
|
//add track element to jukebox
|
|
$keys = $dom->createElement($key,$value);
|
|
$artikel->appendChild($keys);
|
|
|
|
}
|
|
}
|
|
$dom->formatOutput = true; // set the formatOutput attribute of domDocument to true
|
|
|
|
// save XML as string or file
|
|
$test1 = $dom->saveXML(); // put string in test1
|
|
echo $test1;
|
|
//$dom->save('test1.xml'); // save as file
|
|
?>
|