Using PHP and mysql to create XML

There might be scenario where you need to create XML files from the data available in a mysql database. You can use the PHP functions to connect to the database and build the XML file from the scratch or use the DOM functions to create the XML file. Either way you can achieve that.

_______________________________________________


_______________________________________________


You can use the mysql_connect function to connect to your mysql database. This function takes the server in which the database is hosted, the username and the password as the arguments. The mysql_select_db function is used to select the database in which you are going to work and use the mysql_query to get the result of the query on a particular table.

The mysql_query function takes the query and the connection variable as the arguments. The result of the query is assigned to an variable and the number of rows in this variable is checked to see if there are any records out of the query.

If there are any rows present, then you can build the XML file using a while loop. The simplest way is to concatenate variable to the different elements within the loop. If needed, you can write the result in a file using the fopen, fwrite, and fclose functions.

The Never-Ending Debate of Specialist v. Generalist (Java World)
Submitted by Ted Neward on Thu, 08/14/2008 - 15:38. Another DZone newsletter crosses my Inbox, and again I feel compelled to comment. Not so much in the uber-aggressive style of my previous attempt, since I find myself more on the fence on this one, but because I think it's a worthwhile debate and worth calling out.

Add Java extensions to your wiki (Java World)
Wikipedia may be the most high-profile example of a user-edited wiki site, but millions of people around the world are setting up wikis for knowledge-sharing on a smaller scale.

Web Developer (just-auto)
The Position: Hi > > innoSoul, Inc. is a technology driven IT solutions Company providing innovative research and development services, solutions, and resources. We partner with our clients to improve their business performance by providing innovative Information Technology solutions.




FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________

Recommended XML Books

cover
cover
cover
cover
cover
cover






 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!


New XML Books Titles - Best Seller's @ Amazon.com

Visit XML Training Material Guide Homepage

Technology helps engage students - how do classroom instruction and social dynamics change when the classroom is completely dependant on modern technology?

Dallas Web Design- local Dallas web design firm offers site design and backend system development