I need to create a .csv on the fly from a simple select * from table. Instead of listing it on the page I need it to write either a .csv or an .xls comma delimited file. Anyone know the best way to do this or can point me in the right direction? Thanks.
Mark
Pulling a .csv out of a database
Moderator: General Moderators
-
mccommunity
- Forum Commoner
- Posts: 62
- Joined: Mon Oct 07, 2002 8:55 am
My usual steps for this.
1. Run the query
2. Create the column headings using the rows returned form the query(must be using associative array results).
3. Loop through the results and add them to a variable(comma seperated if you like) with a new line at the end of each row.
4. clean the output buffers, send the correct headers to force a download and echo out the variable you saved the data to
Keith
1. Run the query
2. Create the column headings using the rows returned form the query(must be using associative array results).
3. Loop through the results and add them to a variable(comma seperated if you like) with a new line at the end of each row.
4. clean the output buffers, send the correct headers to force a download and echo out the variable you saved the data to
Keith