This stuff got me a day ... But in the end it was impossible to realize the effect that I had imagined ... It's a pity ... It seems that PHP also need to strengthen the XML ... If there's any research on this. Welcome Letter to discuss ...
First build the table:
CREATE TABLE Books (
BookID Int (4) not NULL auto_increment,
BookName varchar (+) not NULL,
Bookauth varchar () not NULL,
Bookpublisher varchar () not NULL,
Bookpubdate datetime not NULL,
Bookurl varchar () not NULL,
KEY BookID (BookID),
);
And then... This is the source code that translates data from MySQL into 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 "Write file successfully!";
}
else{
echo "Writing file failed!";
}
?>
This is the source code that takes data from XML into HTML ...
Class xml{
var $parser;
http://www.bkjia.com/PHPjc/631451.html www.bkjia.com true http://www.bkjia.com/PHPjc/631451.html techarticle this stuff got me a day ... But in the end it was impossible to realize the effect that I had imagined ... It's a pity ... It seems that PHP also need to strengthen the XML ... If any ...