:
<?php
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
$sql = "SELECT bestellpositionen.id_bestellung, bestellpositionen.id, bestellpositionen.anzahl, produkte.preis * bestellpositionen.anzahl AS preisGesamt, bestellpositionen.id_produkt, produkte.name, produkte.beschreibung, produkte.preis AS preisEinzeln FROM bestellpositionen LEFT OUTER JOIN produkte ON (produkte.id = bestellpositionen.id_produkt) ORDER BY bestellpositionen.id_bestellung";
$result = $db->query($sql);
?>
<statistik>
<?php
foreach ($result as $row) {
echo '<bestellung id="' . $row['id_bestellung'] . '">';
echo '<bestellposition id="' . $row['id'] . '">\n';
echo " <anzahl>. $row['anzahl'] .</anzahl>\n\n";
echo " <preis>. $row['preisGesamt'] .</preis>\n\n";
echo '<produkt id="' . $row['id_produkt'] . '">\n';
echo " <name>. $row['name'] .</name>\n\n";
echo " <beschreibung>. $row['beschreibung'] .
</beschreibung>\n\n";
echo " <preis>. $row['preis'] .</preis>\n\n";
echo "</produkt>";
echo "</bestellposition>";
echo "</bestellung>";
}
?>
</statistik>
私は次のエラーを取得しています:私のコードを以下に示します。この方法を試してください。
は、ライン13上のたとえばあなたが
echo " <anzahl>. $row['anzahl'] .</anzahl>\n\n";
を持っていたところ、それはリットル必要としてOOKこのような:
echo " <anzahl>". $row['anzahl'] ."</anzahl>\n\n";
あなたの全体のブロックを使用すると、上記のコメントで述べたように
error on line 2 at column 1: Extra content at the end of the document
あなたの2番目のエラーについては、この
<?php
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
$sql = "SELECT bestellpositionen.id_bestellung, bestellpositionen.id, bestellpositionen.anzahl, produkte.preis * bestellpositionen.anzahl AS preisGesamt, bestellpositionen.id_produkt, produkte.name, produkte.beschreibung, produkte.preis AS preisEinzeln FROM bestellpositionen LEFT OUTER JOIN produkte ON (produkte.id = bestellpositionen.id_produkt) ORDER BY bestellpositionen.id_bestellung";
$result = $db->query($sql);
echo "<statistik>";
foreach ($result as $row) {
echo '<bestellung id="' . $row['id_bestellung'] . '">';
echo '<bestellposition id="' . $row['id'] . '">\n';
echo " <anzahl>". $row['anzahl'] ."</anzahl>\n\n";
echo " <preis>". $row['preisGesamt'] ."</preis>\n\n";
echo '<produkt id="' . $row['id_produkt'] . '">\n';
echo " <name>". $row['name'] ."</name>\n\n";
echo " <beschreibung>". $row['beschreibung'] ."</beschreibung>\n\n";
echo " <preis>". $row['preis'] ."</preis>\n\n";
echo "</produkt>";
echo "</bestellposition>";
echo "</bestellung>";
}
echo "</statistik>";
?>
のようになります。あなたの質問では、この問題をcで解決することができました
header("Content-type: text/xml");
はあなたがすべてのエラーメッセージを投稿してくださいすることができ、このコード行をommenting、または出力あなたは –
は必ず私がポスト:) –
「anzahl」実際のラインまでよりerrosがあると行にエラーイスト編集してきています18とその後、私はこのエラーを取得します - > 2行目の1列目のエラー:ドキュメントの末尾の余分な内容 –