Php xml of MySQL

Source: Internet
Author: User
Tags php download windows 5

Php xml of MySQL
The PHP download page contains two files: a ZIP file and an installation file. Because we need to add extensions in the ZIP file, both files must be downloaded. The following is a simple step:

1. Use the installation file to install PHP;

2. Decompress iconv. dll and place it in the Windows system folder;

3. Create a directory under the PHP installation directory (C: PHP by default) "extensions ";

4. decompress the PHP_domxml.dll file to this directory;

5. Find the PHP. ini file in the Windows folder and open it in notepad or another text editor. Find "extensions_dir =" in this file, and change its value to the full path of the extension folder set in step 1;

6. Find "; extension = PHP_domxml.dll" and delete the semicolon starting with this line;

7. Restart the Web server.

Then, use the following code in your Web directory to create a PHP page named "test. PHP ". (This code runs properly on Windows 5.0 SP3 running IIS 2000 .)

Reference content is as follows:
Run_ SQL _return_xml ("SELECT * FROM users ");

ClassCMySQLXML {

Var $ host;

Var $ user;

Var $ password;

Var $ db;

FunctionCMySQLXML ($ host, $ user, $ password, $ db ){

$ This-> host = $ host;

$ This-> user = $ user;

$ This-> password = $ password;

$ This-> db = $ db;

}

Functionrun_ SQL _return_xml ($ SQL _string ){

$ Connection = MySQL_connect ($ this-> host, $ this-> user, $ this-> password,

$ This-> db );

MySQL_select_db ($ this-> db );

$ Result = MySQL_query ($ SQL _string );

$ Doc = domxml_open_mem ("");

While ($ row = mysql_fetch_array ($ result, MySQL_ASSOC )){

$ Num_fields = MySQL_num_fields ($ result );

$ Row_element = $ doc-> create_element (MySQL_field_table ($ result, 0 ));

$ Doc_root = $ doc-> document_element ();

$ Row_element = $ doc_root-> append_child ($ row_element );

For ($ I = 0; $ I <$ num_fields; $ I ++ ){

$ Field_name = MySQL_field_name ($ result, $ I );

$ Col_element = $ doc-> create_element ($ field_name );

$ Col_element = $ row_element-> append_child ($ col_element );

$ Text_node = $ doc-> create_text_node ($ row [$ field_name]);

$ Col_element-> append_child ($ text_node );

}

}

MySQL_free_result ($ result );

MySQL_close ($ connection );

Return $ doc-> dump_mem (false );

}

}
 

 

Related Article

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.