DB
Date Price qty
2012-10-21 $11 150
2012-10-22 $12 90
2012-10-22 $12 10
2012-10-23 $13 250
CODE
$result = mysqli_query($con, "SELECT * FROM table ORDER BY 'date'");
while ($row = mysqli_fetch_array($result)) {
$orders[] = array(
'Date' => $row['date'],
'price' => $row['price'],
'Quantity' => $row['qty']
);
}
I don't need to get duplicate dates and for those duplicate dates need to get Average price
and sum of Qty
like below example:
EXAMPLE
Date Price qty
2012-10-21 $11 150
2012-10-22 $12 100
2012-10-23 $13 250
I try to use Array-map
but i fail on that help is really appreciated