PHP writes XML file the Word table data read only one piece of data, what reason

Source: Internet
Author: User
Tags php write
Help PHP write XML file The Word table data read only one data, what reason
PHP based on the primary table type traversal from the table for data generation MXL file data only displays one specific following

Include ("admin.php");
if (File_exists (". /xml/list.xml "))
{
Unlink (".. /xml/list.xml ");//exist first delete
}
Create DOCTYPE Header
$dom = new DOMDocument ("1.0", "Utf-8");
Create root element for image
$root = $dom->createelement ("list");
$dom->appendchild ($root);
$dom->formatoutput=true;

$sqlClass = "Select Music_class from Dj_class";//Read data from the database
$resClass = mysql_query ($sqlClass);
while ($rowClass = Mysql_fetch_array ($resClass))
{
$music _class = $rowClass [' music_class '];//read field

$item = $dom->createelement ("M");
$root->appendchild ($item);

$item _url = $dom->createattribute ("label");
$item->appendchild ($item _url);
$item _urlvalue = $dom->createtextnode ($music _class);
$item _url->appendchild ($item _urlvalue);


$item _URLX = $dom->createelement ("M");
$item->appendchild ($item _urlx);


echo "$music _class";
echo "
";
echo "";
$sqlMusic = "SELECT * from Dj_music where music_ishtml= ' $music _class '";//Read data from database

$resMusic = mysql_query ($sqlMusic);


$SQLC = "SELECT count (*) as Count from Dj_music where music_ishtml= ' $music _class '";
$result =mysql_fetch_array (mysql_query ($SQLC));
$count = $result [' count '];


echo "$count";
echo "
";



if ($count >0) {//here to determine if there is data



for ($i = 0; $i < $count; $i + +)
{
while ($rowMusic = Mysql_fetch_row ($resMusic))
{
echo "$rowMusic [1]";
echo "$rowMusic [2]";

echo "
";

$item _url = $dom->createattribute ("type");
$item _urlx->appendchild ($item _url);
$item _urlvalue = $dom->createtextnode ("");
$item _url->appendchild ($item _urlvalue);

$item _url = $dom->createattribute ("src");
$item _urlx->appendchild ($item _url);
$item _urlvalue = $dom->createtextnode ($music _url);
$item _url->appendchild ($item _urlvalue);

$item _url = $dom->createattribute ("LRC");
$item _urlx->appendchild ($item _url);
$item _urlvalue = $dom->createtextnode ("$rowMusic [2]");
$item _url->appendchild ($item _urlvalue);

$item _url = $dom->createattribute ("label");
$item _urlx->appendchild ($item _url);
$item _urlvalue = $dom->createtextnode ("$rowMusic [1]");
$item _url->appendchild ($item _urlvalue);

}

}

}else {
echo "No data";
echo "
";
}

}

Save Tree to File
$dom->save (". /xml/list.xml ");//save to the specified directory
Header ("location:content_show.php");
?>



The result of PHP output is

Tian Ao Online Games Guild
Wwww
Rich Games Guild
Tick.. /xml/music/Sword is like a dream. mp3
Phoenix legend. /xml/music/Sword is like a dream. mp3
The scattered People's Paradise Guild
The sword is like a dream. /xml/music/Sword is like a dream. mp3

The resulting XML is






  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.