Using PHP to dynamically generate XML files and extract data from XML files into HTML applets... Don't use DOM... This stuff took me a day... However, at the end, I found that I could not achieve the effect I imagined... It's a pity... It seems that PHP still needs to strengthen XML... If any of these things took me a day... However, at the end, I found that I could not achieve the effect I imagined... It's a pity... It seems that PHP still needs to strengthen XML... If anyone has research on this. Thank you for writing to us...
Create a table first:
Create table books (
Bookid int (4) not null auto_increment,
Bookname varchar (100) not null,
Bookauth varchar (50) not null,
Bookpublisher varchar (50) not null,
Bookpubdate datetime not null,
Bookurl varchar (50) not null,
KEY bookid (bookid ),
);
Then... This section is the source code for converting data from MYSQL to XML:
$ Connect_id = mysql_connect ("localhost", "root ","");
Mysql_select_db ("bbs", $ connect_id );
$ Query = "select * from books order by bookid ";
$ Rs = mysql_query ($ query, $ connect_id );
$ Numfields = mysql_num_fields ($ rs );
$ Xmlfile =" ";
$ Xmlfile. =" ";
While ($ row = mysql_fetch_array ($ rs )){
For ($ I = 0; $ I <$ numfields; $ I ++ ){
$ Fieldname = mysql_field_name ($ rs, $ I );
$ Xmlfile. = "<". $ fieldname. ">". $ row [$ I]." ";
}
}
Mysql_free_result ($ rs );
Mysql_close ($ connect_id );
$ Xmlfile. =" ";
$ Fp = fopen ("xmldoc/xmldoc. xml", "w ");
If (fwrite ($ fp, $ xmlfile )){
Echo "file written! ";
}
Else {
Echo "failed to write file! ";
}
?>
This section is the source code for converting data from XML into HTML...
Class xml {
Var $ parser;
Bytes... However, at the end, I found that I could not achieve the effect I imagined... It's a pity... It seems that PHP still needs to strengthen XML... If any...