how to picks the data from database and put into csv file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manohar
Forum Newbie
Posts: 10
Joined: Thu Jun 26, 2008 10:49 am

how to picks the data from database and put into csv file

Post by manohar »

I want to download csv file containing states.All states are available in the states table
Any one can pls help me
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Re: how to picks the data from database and put into csv file

Post by Kadanis »

There are 2 ways I can think of to do this.

Either you connect to the database, iterate over the table and output it to a page. Make sure you set the page content type to csv and as a download and you should be fine. Or, you could use the MySQL OUTFILE command.

Code: Select all

 
SELECT * INTO OUTFILE ...
 

Google is your friend

http://www.ineedtutorials.com/articles/ ... p-tutorial
Post Reply