Re: PHP export to CSV

From: Date: Mon, 22 Dec 2003 15:32:39 +0000
Subject: Re: PHP export to CSV
Groups: php.db 
Request: Send a blank email to php-db+get-32161@lists.php.net to get a copy of this message
using mysql as an example, this is what i do. ---UNTESTED CODE -- $sql = "SELECT * FROM TABLE"; $res = mysql_query($sql) or die(mysql_error() . "<br>".$sql); $fp = fopen("file_to_create.csv", "w"); while ($rs = mysql_fetch_row($res)) { $write_string = "\" . implode("\",\"", $rs) . "\" \n"; fwrite($fp, $write_string); } fclose($fp); This would produce a fully quoted csv file. edit to you liking. hth Jeff "John Greco" <john@rabweb.com> To: php-db@lists.php.net cc: 12/22/2003 10:20 Subject: [PHP-DB] PHP export to CSV AM Please respond to "John Greco" 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

« previous php.db (#32161) next »