Combined Use of PHP, XML, XSLT, and MySQL

Source: Internet
Author: User
Tags xsl file

I. integration and application of php, XML, XSLT, and Mysql
I often see some posts about the combination of php, XML, and database, and some beginners.
The php code and HTML code are mixed together, and the error cannot be found in the case of an error. The error is so anxious that I will give it a big one.
Let's talk about how to use XML technology to separate HTML code from PHP programs. Of course, there are many separation technologies, such as PEAR
IT template.
In general, I personally think that using XML technology is the most convenient. If you don't talk much about it, let's get down to the truth,
Let's talk about the installation in win2000.

Some dll libraries are required to use xml and xslt in php,
Extension = php_domxml.dll // function library for operating XML
Extension = php_iconv.dll // For transcoding, for example ?????? Of the UTF-8.
Extension = php_xslt.dll // function library of XSLT

When using the above three libraries, you need to add the dlls directory under the php installation directory to the path, otherwise it will not be found
The

In the following course, we will use the PEAR class library in php, mainly using the DB class library and Sql2XML class library.
Download the latest pear.php.net version.
After downloading the above two class libraries, you 'd better set them in php. ini.
Include_path = ".; d: phppear"

D: phppear is the installation path of my pear.

After the configuration is complete, restart the machine. Otherwise, Apache cannot be started properly because the path cannot be found.


Now we have to use the XML and XSLT settings in PHP. Isn't it easy?
Linux users can
Http://www.gingerall.com/download the source code for release t.
Http://www.gnu.org/software/libicon...for iconvsource code

The combination of php, XML, XSLT, and Mysql
Next I will talk about a simple process of extracting data from the database, generating XML documents, and converting to HTML using XSLT,
This process only describes the process of using this technology, and does not involve paging and other technologies.

In this example, I use the following database tables and data
Table Name: enterprise user information table, English name: yhxx
Table Structure:
#
# Data table structure 'hxx'
#

Create table yhxx (
Nsnm varchar (15) not null default '',
Qymc varchar (200) not null default '',
Qydh varchar (50) not null default '',
Primary key (nsnm)
) TYPE = MyISAM COMMENT = 'user info table ';

#
# Data table content 'hxx'
#

Insert into yhxx VALUES ('20170101', 'qiao Jia Food Development Co., Ltd. ', '2017-123 ');
Insert into yhxx VALUES ('20170101', 'shanghai Jialing Trading Co., Ltd. ', '20170101 ');
Insert into yhxx VALUES ('20170101', 'emerald art company', '20160301 ');


Next, I will write the data extraction program and the data display page.
To make everyone understand, I use the simplest method to write programs.

Program file name: browesData. php
Page file name: browesData.html
Download programs and page files. This program has passed testing in win2000 and mysql.
For the code, see the next page.


If you are interested in this technology, I would like to share with you the more in-depth application of php in combination with xml, xslt, and databases.

?>
GetMessage (); // connection failure, error message output
}

// The following two are public functions.
/**
* Reading the xsl document
*
* @ Param String $ filename-xsl file name
* @ Return string

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.