PHP Arrays: Grouping, Sum -
i'm trying print out shopping cart orders, however, instead of displaying products order want group orders order id can display sum of order , link detail page.
instead of this
--------------------------------------- date order number total --------------------------------------- today 1234wedk 600 --------------------------------------- today 1234wedk 500 ---------------------------------------
i'd display this
--------------------------------------- date order number total --------------------------------------- today 1234wedk 1100 ---------------------------------------
here's sample array
array:2 [▼ 0 => array:9 [▼ "id" => 57 "order_id" => 51 "order_hash" => "1234wedk" "price" => 600 ] 1 => array:9 [▼ "id" => 58 "order_id" => 51 "order_hash" => "1234wedk" "price" => 500 ] ]
assuming getting data database, should make calculations
select order_hash, date, sum(price) total cart group order_hash
Comments
Post a Comment