RE: [PHP-DB] PHP export to CSV
| From: | Gary Every | Date: | Mon, 29 Dec 2003 16:37:29 +0000 |
| Subject: | RE: [PHP-DB] PHP export to CSV | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-32208@lists.php.net to get a copy of this message | ||
You should try this:
Header("Content-Type: text/plain");
Header("Content-Disposition: attachment; filename=file.csv");
Then output the text you want to send. Make sure you double-quote it so that the newlines work!
$eol = "\n";
echo "Field 1,Field 2,$field_variable,$eol"
......
This sends a stream of info WHEN THE USER DECIDES what to do with it.
That means if they click cancel, the file is not created, and you have no cleanup
Works great!
-----Original Message-----
From: John Greco [mailto:john@rabweb.com]
Sent: Monday, December 22, 2003 9:20 AM
To: php-db@lists.php.net
Subject: [PHP-DB] PHP export to CSV
Anyone ever get some code to select from the DB and drop into a CSV file?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php