Make CSV File from Database
This is the easiest way to make a CSV file from a database query and output it to the user for download. This simple code uses the PHP5 fputcsv function to correctly format an array of values into a line in a csv file. It does not use the physical file so you do not need any write permissions where you use this code, as it uses the memory buffer instead.
PHP:
-
-
-
$record[] = $data['param1'];
-
$record[] = $data['param2'];
-
$record[] = $data['param3'];
-
-
fputcsv($output, $record);
-
}
-
-
-
-
-
echo $output;












