我有一个这种格式的 php 文件:
<?php
$username = "root";
$password= "";
$db = "kamus1";
mysql_connect("localhost",$username,$password) or die("koneksi ke MySQL gagal");
mysql_select_db($db) or die ("koneksi ke dataBase gagal");
$doc = new DomDocument('1.0');
$root = $doc->createElement('movies');
$root = $doc->appendChild($root);
$arr = array();
//$query=mysql_query("select id,istilah,definisi from kamus_jaringan");
$query=mysql_query("select * from kamus_jaringan");
while($get_data = mysql_fetch_array($query))
{
foreach($get_data as $fieldname=>$fieldvalue)
{
$item = $doc->createElement('movie');
$item = $root->appendChild($item);
$item ->setAttribute("id",$get_data["id"]);
$item ->setAttribute("istilah",$get_data["istilah"]);
$item ->setAttribute("definisi",$get_data["definisi"]);
}
}
echo $doc->saveXML();
$doc->save("movies.xml");
?>
当这段代码在浏览器上执行时,每个数据的输出最多会重复六次。例如 id,将重复六次。我想要每个数据的输出,只有一次。请帮忙