日期:2014-05-17 浏览次数:20475 次
<?PHP $id=$_GET['number']; include("conn.php"); $Date = date("YmdHis"); $Filename = $Date.".csv"; $Table = isset($_GET['tid'])?$_GET['tid']:''; header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=".$Filename); echo "SKU,product-name,sum(quantity),\r\n"; $Sql = "select *,sum(`quantity-purchased`) from sale_orders WHERE `number`=$id group by `jj_sku`"; $Result = mysql_query($Sql); while($rs = mysql_fetch_array($Result) ){ $j_sku=$rs['jj_sku']; $Sqlpr = "SELECT `product-name` FROM `product_co` WHERE `jj_sku`=$j_sku"; $Resulta = mysql_query($Sqlpr,$conn); $resultaa= mysql_fetch_row($Resulta); $pro-nm=$resultaa[0]; echo $rs['jj_sku'].",".$pro-nm.",". $rs['sum(`quantity-purchased`)']." \r\n "; } ?>