RE: [PHP-DB] PHP export to CSV

2003-12-29 Thread Gary Every
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 st

Re: [PHP-DB] PHP export to CSV

2003-12-22 Thread jeffrey_n_Dyke
using mysql as an example, this is what i do. ---UNTESTED CODE -- $sql = "SELECT * FROM TABLE"; $res = mysql_query($sql) or die(mysql_error() . "".$sql); $fp = fopen("file_to_create.csv", "w"); while ($rs = mysql_fetch_row($res)) { $write_string = "\" . implode("\",\"", $rs) . "\" \n";