当前位置:Gxlcms > PHP教程 > 数组合并排序有关问题

数组合并排序有关问题

时间:2021-07-01 10:21:17 帮助过:5人阅读

数组合并排序问题
本帖最后由 lazygc520 于 2013-06-07 09:37:32 编辑


$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, ' ', '' )";
$result = mysql_query($sql);
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 order by lotno asc";
$result2 = mysql_query($sql2);
$var = array();
while($row2 = mysql_fetch_array($result2,MYSQL_NUM))
{

$var[] = array('lotno'=>$row2[0],'count'=>$row2[1]);
}
print_r($var);
}

// echo $a[$k]['5'].'
';
?>


得到的结果:

Array
(
[0] => Array
(
[lotno] => 3207
[count] => 15
)

)
Array
(
[0] => Array
(
[lotno] => 3207
[count] => 15
)

)
Array
(
[0] => Array
(
[lotno] => 3206
[count] => 12
)

[1] => Array
(
[lotno] => 3207
[count] => 3
)

)
Array
(
[0] => Array
(
[lotno] => 3207
[count] => 15
)

)
Array
(
[0] => Array
(
[lotno] => 3207
[count] => 15
)

)
Array
(
[0] => Array
(
[lotno] => 3218
[count] => 15
)

)
Array
(
[0] => Array

人气教程排行