Why does PHP write a single piece of data into the word table of an XML file?

Source: Internet
Author: User
Tags php write
Ask PHP to write data into the XML file. The word table reads only one piece of data. Why does PHP traverse the data from the table based on the type in the master table? & nbsp; generate mxl & nbsp; only one & nbsp; file data is displayed as follows & lt ;? Phpinclude ("admin. php"); if (file_exists ("../xml/list. x ask PHP to write data into an XML file. The word table reads only one piece of data. why?
PHP traverses the data from the table based on the type of the master table. only one message is displayed for the mxl file generated for the data as follows:

Include ("admin. php ");
If (file_exists ("../xml/list. xml "))
{
Unlink ("../xml/list. xml"); // if it exists, delete it first.
}
// Create doctype header
$ Dom = new DOMDocument ("1.0", "UTF-8 ");
// Create root element
$ 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 a 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 the 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) {// check whether data exists here



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 it to the specified directory
// Header ("location: content_show.php ");
?>



Php output:

Tiao Online Game Association
Wwww
Haomen webgame Association
Tick ../xml/music/Swordsman
Legend of Phoenix ../xml/music/Swordsman
Slab
A sword is like a dream ../xml/music/sword is like a dream

If xml is generated






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.