我有这个代码可以从 mysql 导出到 wordpress 中的 Excel 我用链接调用这个文件
<?php include("header.php");
$table = 'driver_detail';
$file = 'export';
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j]."; ";
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
但我有这个错误..如何解决这个问题
Warning: Cannot modify header information - headers already sent by (output started at /home5/revoluv0/public_html/proj/autobodyparts/get-details/header.php:3) in /home5/revoluv0/public_html/proj/autobodyparts/get-details/export-driver.php on line 24