以下代码中的所有内容似乎都可以正常工作,因为它确实从表中下载了数据,但是列名称未在csv中显示是什么问题?
$stmt = $db->prepare("select * from interviews");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$filename = "export.csv";
$f = fopen('php://output', 'w');
header('Content-Type: text/csv');
header('Content-Disposition: attachement; filename="export.csv"');
header("Pragma: no-cache");
header("Expires: 0");
foreach ($rows as $line) {
fputcsv($f, $line);
}
fclose($f);
谢谢