时间:2021-07-01 10:21:17 帮助过:17人阅读
header('Content-Type: application/vnd.ms-excel;charset="gbk"');
header('Content-Disposition: attachment;filename="user.csv"');
header('Cache-Control: max-age=0');
$fp = fopen('php://output', 'a');
$head = array('仓库', '编码', '名称', '规格', '数量', '单位');
fputcsv($fp, $head);
// 计数器
$conn = mysql_pconnect("localhost",'root','root');
mysql_select_db("jhdb",$conn);
$sql = "select b.name,a.Code,c.cName,c.cStd,a.num,c.cUnit from jh_kc a,jh_ck b,jh_inventory c where a.Code=c.Code and a.ckid=b.id and a.ckid=".$_REQUEST["ckid"];
$result = mysql_query($sql,$conn) or die(msgbox("SQL出错:".$sql));
while($myrow = mysql_fetch_array($result,MYSQL_BOTH))
{
fputcsv($fp, $myrow);
}
mysql_free_result($result);
?>