求一填值效果
<br> <?php <br /> $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, ' ', '' )";<br> // echo $sql.'<br>';<br> $result = mysql_query($sql);<br> $res = array(); <br> while($row = mysql_fetch_array($result,MYSQL_ASSOC))<br> {<br> $sql2 = "select lotno,count(lotno) from `vp_barcode_2d_y` where packageno = '".$row['packageno']."' group by lotno,packageno order by lotno asc";<br> // echo $sql2.'<br>';<br> $result2 = mysql_query($sql2);<br> $var = array();<br> while($row2 = mysql_fetch_array($result2,MYSQL_NUM))<br> {<br> if(isset($res[$row2[0]])) <br> $res[$row2[0]]['count'] += $row2[1];<br> else <br> $res[$row2[0]] = array('lotno'=>$row2[0],'count'=>$row2[1]);<br> }<br> }<br> ksort($res);<br> $arrs = array();<br> foreach($res as $v2)<br> {<br> $arrs[] = $v2;<br> }<br> print_r($arrs);//Array ( [0] => Array ( [lotno] => 3207 [count] => 240 ) ) <br> <br> <br> $sql4 = "select arr_time,c_type,cust_no,snp,mount,mount*snp as m_total from `".$t."` where stock_no = '".$stockno[$j-1]."'";<br> $result4 = mysql_query($sql4);<br> $a = array();<br> while($var = mysql_fetch_array($result4,MYSQL_NUM))<br> {<br> $a[] = $var;<br> }<br> foreach($a as $k=>$v)//显示一个stockno对应的两行结果<br> {<br> echo '<br> <tr> <br> <td> <br> '.($k+1).'</td>';<br> ?><br> <td> <br> <?php <br /> echo $v['0'];<br> ?></td> <br> <td> <br> <?php <br /> echo $v['1'];<br> ?></td> <br> <td> <br> <?php <br /> echo $v['2'];<br> ?></td> <br> <td> <br> <?php <br /> $sql = "select type from `kw_info` where cust_no = '".$v['2']."'";<br> $result = mysql_query($sql);<br> $row = mysql_fetch_array($result,MYSQL_ASSOC);<br> echo $row['type']; <div class="clear"> </div> </td> </tr>