RE: PHP export to CSV

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx]
Sent: Monday, December 22, 2003 9:20 AM
To: php-db@xxxxxxxxxxxxx
Subject:  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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux