php - fputcsv prints result to screen instead into csv -


i trying export database data .csv via php. after length of data doesn't save query .csv file displays on screen. looks it's independent on records queried, , seems independent of special characters.

$handle = fopen("php://output", "w"); fputcsv($handle, array('name','text','link','category','price','package', 'date of upload','date of verification','date of expiry','status','clk')); ($c=0; $c<$num_rows; $c++) {     $row2[$c][0] = iconv("utf-8","windows-1257",html_entity_decode( $row2[$c][0] ,ent_compat,'utf-8'));     $row2[$c][1] = iconv("utf-8","windows-1257",html_entity_decode( $row2[$c][1] ,ent_compat,'utf-8'));     fputcsv($handle, array($row2[$c][0], $row2[$c][1], $row2[$c][2], $row2[$c][3], $row2[$c][4], $row2[$c][5], $row2[$c][6], $row2[$c][7], $row2[$c][8], $row2[$c][9], $row2[$c][10])); } fclose($handle);  header('content-type: text/csv; utf-8'); header("content-disposition: attachment; filename=".$filename); header("pragma: no-cache"); header("expires: 0"); 

11 columns, 18 records. 19 records it's not working.

am missing setting?

place headers before output!


if convert to utf use:

iconv("windows-1257", "utf-8", ... 

the order of arguments wrong


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -