我正在尝试通过 php 将数据库数据导出到 .csv 中。经过一定长度的数据后,它不会将查询保存到 .csv 文件中,而是将其显示在屏幕上。看起来它与查询哪些记录无关,而且似乎也与任何特殊字符无关。
$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'));
for ($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 列,18 条记录。有 19 条记录,它不起作用。
我错过了一些设置吗?