php - Why using exit(); it stores only one row in csv file from selected data? -
i stuck on 1 problem... example, using exit();
works, works first selected row, not all. if using echo display data, displays perfecly. if trying make work without exit(); not work @ all. suggestions how fix this?
$vet = $_get['vet']; $name = $_get['name']; // etc... $data = fopen('php://output', 'w'); fputcsv($data,array('id', 'name', 'email address', etc...)); // selection query (it works perfecly) foreach... // echo query tests (it works perfectly) fputcsv($data, array($id, $name, $email, etc...)); header('content-type: text/csv; charset=utf-8'); header('content-disposition: attachment; filename='. $name .'.csv'); exit(); endforeach....
the header
s & exit
should after loop
ends. adding first row , exiting loop. result 1 row present. loop should run iterations add rows file.
foreach... // echo query tests (it works perfectly) fputcsv($data, array($id, $name, $email, etc...)); endforeach.... header('content-type: text/csv; charset=utf-8'); header('content-disposition: attachment; filename='. $name .'.csv'); exit();
Comments
Post a Comment