首頁  >  文章  >  後端開發  >  数组合并排序有关问题

数组合并排序有关问题

WBOY
WBOY原創
2016-06-13 12:47:18951瀏覽

数组合并排序问题

本帖最后由 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 />


得到的结果:

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>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn