dcolumbus
dcolumbus

Reputation: 9722

PHP: Export DB Table to CSV FILE

I've got a custom table in WordPress and I'd like to be able to export the data in that table as a FILE in CSV (semi-colon seperated) format.

I've got the data coming out properly, but how do I then save it as an attachment?

Keep in mind that when using WordPress, headers have already been set... and I really don't know how to get around that.

Upvotes: 1

Views: 8766

Answers (3)

Umair Idrees
Umair Idrees

Reputation: 1436

you can use this code. just copy and past and you have it :)

https://gist.github.com/umairidrees/8952054#file-php-save-db-table-as-csv

Upvotes: -1

Raptor
Raptor

Reputation: 54212

For these plugins, they use database to store row & column details. You have to extract the data in MySQL database tables ( those table names are usually named after the plugin's name ) .

If you are still not sure how to do, you can just copy the table being displayed in page in browser, then paste in Excel. Last, save as CSV or XLS if you like.

Upvotes: 0

paulsm4
paulsm4

Reputation: 121599

I'm not sure exactly HOW you're doing what you're TRYING to do ...

... but this link gives you a simple, straightforward way to write the data as a .csv file you can do a "save as" from your browser:

http://wordpress.org/support/topic/export-wordpress-db-table-to-excel

Upvotes: 3

Related Questions