Jump to content

Export MYSQL to CSV or Access DB via PHP


radar

Recommended Posts

I've got a database that I've just finished the web application on.  It has like 10 tables, 6 of them I need to be able to export either to CSV or to an Access DB file that when the client clicks on the button to export, it opens the dialog for them to save it.

 

I've got no clue how to do either of these things, so anything you can do to help me would be appreciated.

 

Thanks,

Radar

You can try this query; although a peer of mine passed it on, I have not tried it myself:

SELECT id, name, email INTO OUTFILE '/tmp/records.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ‘\\’
LINES TERMINATED BY '\n'
FROM users WHERE 1

 

From there, all you have to do is open records.csv and fetch it to the browser.

 

Angel

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.