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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -