Possible Duplicate:
PHP code to convert a MySQL query to CSV
What is the best and cleanest way to export mysql query to CSV (for Excel 2003 and later)? "Best" in terms of being tested, maintained, configurable ... so something like a (standard) PHP library would be the ideal solution.
It should correctly handle enclosure, escaping, charset, cr-lf, field names in 1st row, ... etc.
There have been couple of questions on this here at SO (like this one) but none really focuses on the properties I require above.
Some ideas of mine:
- use
fputcsv
? (but charset, escaping and cr-lf seemingly cannot be set!) - extract some code from phpmyadmin...?
SELECT * INTO OUTFILE
doesn't work at my server (access denied)system("mysqldump ...")
is not possible (safe mode hosting)