Return to Snippet

Revision: 50794
at September 3, 2011 11:34 by FatFolderDesigner

Initial Code
require '../includes/init.php'; // This connects to the database
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=client_export.csv");
header("Pragma: no-cache");
header("Expires: 0");
$q=mysql_query('select * from users');
	foreach($r as $k => $v){
			echo '"'.str_replace('"', '""', $v).'",';
	echo "\n";

Initial URL

Initial Description
Just a short little script that takes a mysql query and turns it into a csv file that downloads automatically. If your interested in the details you can hit up the link.

Initial Title
Simple MySQL to CSV

Initial Tags
mysql, php, simple, csv

Initial Language