Two problems
1. It is writing the data as one long string. I thought the "\n" would have caused a line break.
2. It is writing the data to the browser. I want it to a file and where does the file get written.
Code: Select all
$query = mysql_query("SELECT distinct(enroll_email) FROM enrollment where enroll_email is not null and enroll_email <> ' ' order by enroll_email");
$file = 'export';
while($row = mysql_fetch_array($query)) {
$enroll .= $row['enroll_email'] . "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/octetstream");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header("Content-disposition: filename=".$filename.".csv");
echo $enroll;
exit;I have tried several types of headers and different file names but no difference.