我有一个有效的导出csv文件代码,在我的标题行之前有3个空白行。我该如何删除空白行?所以标题将位于顶部。
include("global.php");
$Rid = $_SESSION['Rid'];
if(isset($_REQUEST['Rid']))
$Rid = $_REQUEST['Rid'];
else
$Rid = "";
$filename = "$Rid.csv";
$fp = fopen('php://output', 'w');
$header=array("DATE","REFNUMBER","MODEL","DESC","CODE","BAL","QTY");
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
fputcsv($fp, $header);
$query = "SELECT requisition_tb.daterequested ,
requisition_tb.refnumber ,
allinvty3.ecr_desc,
allinvty3.ite_desc,
requisition_tb.itemcode ,
requisition_tb.onhand ,
requisition_tb.qty
from requisition_tb
INNER JOIN allinvty3 on requisition_tb.itemcode = allinvty3.in_code
where requisition_tb.refnumber='".$Rid."'
ORDER BY allinvty3.ecr_desc ASC";
$result = mysql_query($query);
while($row = mysql_fetch_row($result)) {
fputcsv($fp, $row);
}
?>