我在一个包含订单号和其他订单数据的数组中有一堆行:
Array ( [ORDER] => 257 [DATE] => 2011-06-13 [ITEM] => LOT98 [QTYORDERED] => 10.00 )
Array ( [ORDER] => 258 [DATE] => 2011-06-15 [ITEM] => FF25 [QTYORDERED] => 450.00 )
Array ( [ORDER] => 258 [DATE] => 2011-07-06 [ITEM] => FF25 [QTYORDERED] => 225.00 )
Array ( [ORDER] => 259 [DATE] => 2011-06-08 [ITEM] => A151412 [QTYORDERED] => 90.00)
Array ( [ORDER] => 259 [DATE] => 2011-06-15 [ITEM] => A151412 [QTYORDERED] => 402.00 )
Array ( [ORDER] => 259 [DATE] => 2011-07-06 [ITEM] => A151412 [QTYORDERED] => 357.00 )
我想将这些行放入一个按ORDER No分组的数组,其格式与此类似:
Order ID Date Item QTYOrdered
257 0 xx xx xx
258 0 xx xx xx
1 xx xx xx
259 0 xx xx xx
1 xx xx xx
2 xx xx xx
到目前为止我的代码:
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$RecordSet = $db->Execute("$q2");
while ($row = $RecordSet->FetchRow()) {}
答案 0 :(得分:3)
在你的循环中:
$ordered[$row['ORDER']][] = $row;
在循环之后你有:
var_dump($ordered);
根据订单键自动打包在一起。