Maison > Article > développement back-end > 施用fputcsv导出mysql查询内容出现两次
使用fputcsv导出mysql查询内容出现两次
<br /> <?<br /> header('Content-Type: application/vnd.ms-excel;charset="gbk"');<br /> header('Content-Disposition: attachment;filename="user.csv"');<br /> header('Cache-Control: max-age=0');<br /> <br /> $fp = fopen('php://output', 'a');<br /> <br /> $head = array('仓库', '编码', '名称', '规格', '数量', '单位');<br /> <br /> fputcsv($fp, $head);<br /> // 计数器<br /> $conn = mysql_pconnect("localhost",'root','root');<br /> mysql_select_db("jhdb",$conn);<br /> $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"];<br /> <br /> $result = mysql_query($sql,$conn) or die(msgbox("SQL出错:".$sql));<br /> while($myrow = mysql_fetch_array($result,MYSQL_BOTH))<br /> {<br /> fputcsv($fp, $myrow);<br /> }<br /> mysql_free_result($result);<br /> <br /> ?><br />