This post was last edited by lazygc520 on 2013-06-07 09:37:32
$row 2[0], ' count ' = $row 2[1]);} Print_r ($var);} echo $a [$k] [' 5 ']. '
';? >
The results obtained:
Array ([0] = = Array ([Lotno] = 3207 [count] = +)) array ([0] = = Array ([Lotno] = 3207 [count] = +)) array ([0] = = Array ( [Lotno] = 3206 [Count] [1] = = Array ([Lotno] + 3207 [Count] = 3)) array ([0] = = Array ([Lotno] = 3207 [Count] => ; ) array ([0] = = Array ([Lotno] = 3207 [count] = +)) Array ( [0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [Count] = 15)) Array ([0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [count] = =) array ([0] = = Array ([Lotno] = 3218 [count] = +)) Array ( [0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [Count] = 15)) Array ([0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ([Lotno] = 3218 [count] = +)) array ([0] = = Array ( [Lotno] = 3218 [Count] = ()) array ([0] = = Array ([lotno] = = 3218 [Count] = ()) array ([0] = = Array ([Lotno] = 3218 [cou NT] = 15))
How do you combine these two-dimensional arrays into an array and sort by lotno?
If the Lotno phase is the same, the value corresponding to count is added. May I ask how to deal with it?
Reply to discussion (solution)
$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); $res = Array (); Sets an array to hold the result ($row = Mysql_fetch_array ($result, Mysql_assoc)) { $sql 2 = "Select Lotno,count (Lotno) from ' Vp_ Barcode_2d_y ' Where Packageno = ' ". $row [' Packageno ']. ' GROUP by Lotno ORDER by lotno ASC '; $result 2 = mysql_query ($sql 2); $var = Array (); while ($row 2 = mysql_fetch_array ($result 2,mysql_num)) { if (isset ($res [$row 2[0])) $res [$row 2[0]][' count '] + = $row 2[1]; else $res [$row 2[0]] = Array (' lotno ' = = $row 2[0], ' count ' = $row 2[1]);} } Ksort ($res); Because the key name has been processed into a Lotno value, the key name sort is sorted by Lotno