PHP implementation of the dynamic generation of XML files and from the XML file to extract data into the HTML of the applet ... Without Dom's. _php Tutorials

Source: Internet
Author: User
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 ...

  • 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.