日期:2014-05-17 浏览次数:20752 次
<?php
$sql = "select DISTINCT b.packageno,a.stock_no from `stock_detail` as a,`kw_manage` as b where a.stock_no = '".$stockno[$j-1]."' and a.cust_no = replace( b.cust_no, ' ', '' )";
// echo $sql.'<br />';
$result = mysql_query($sql);
$res = array();
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$sql2 = "select lotno,count(lotno) from `vp_barcode_2d_y` where packageno = '".$row['packageno']."' group by lotno,packageno order by lotno asc";
// echo $sql2.'<br />';
$result2 = mysql_query($sql2);
$var = array();
while($row2 = mysql_fetch_array($result2,MYSQL_NUM))
{
if(isset($res[$row2[0]]))
$res[$row2[0]]['count'] += $row2[1];
else
$res[$row2[0]] = array('lotno'=>$row2[0],'count'=>$row2[1]);
}
}
ksort($res);
$arrs = array();
foreach($res as $v2)
{
$arrs[] = $v2;
}
print_r($arrs);//Array ( [0] => Array ( [lotno] => 3207 [count] => 240 ) )
$sql4 = "select arr_time,c_type,cust_no,snp,mount,mount*snp as m_total from `".$t."` where stock_no = '".$stockno[$j-1]."'";
$result4 = mysql_query($sql4);
$a = array();
while($var = mysql_fetch_array($result4,MYSQL_NUM))
{
$a[] = $var;
}
foreach($a as $k=>$v)//显示一个stockno对应的两行结果
{
echo '
<tr height="56" style="height: 42.0pt">
<td>
'.($k+1).'</td>';
?>
<td>
<?php
echo $v['0'];
?></td>
<td>
<?php
echo $v['1'];
?></td>
<td>
<?php
echo $v['2'];
?></td>
<td>
<?php
$sql = "select type from `kw_info` where cust_no = '".$v['2']."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
echo $row['type'];