数组合并排序问题
本帖最后由 lazygc520 于 2013-06-07 09:37:32 编辑
<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."' and a.cust_no = replace( b.cust_no, ' ', '' )";<br />
$result = mysql_query($sql);<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 order by lotno asc";<br />
$result2 = mysql_query($sql2);<br />
$var = array();<br />
while($row2 = mysql_fetch_array($result2,MYSQL_NUM))<br />
{<br />
<br />
$var[] = array('lotno'=>$row2[0],'count'=>$row2[1]);<br />
}<br />
print_r($var);<br />
}<br />
<br />
// echo $a[$k]['5'].'<br />';<br />
?><br />
Copier après la connexion
得到的结果:
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3207<br>
[count] => 15<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3207<br>
[count] => 15<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3206<br>
[count] => 12<br>
)<br>
<br>
[1] => Array<br>
(<br>
[lotno] => 3207<br>
[count] => 3<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3207<br>
[count] => 15<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3207<br>
[count] => 15<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array<br>
(<br>
[lotno] => 3218<br>
[count] => 15<br>
)<br>
<br>
)<br>
Array<br>
(<br>
[0] => Array <div class="clear">
</div>
Copier après la connexion