I would like to have some help with my problem, I am displaying total sales gained within a time period, which i have done successfully and what i need now is how to display all the individual prices that leads to the total. for example total is 10, i bought apple for 4, and oranges for 6, 10 is the total price.
I have here my query for displaying it in a time period using input type date,
$datefrom = $_GET['datefrom'];
$dateto = $_GET['dateto'];
$qry = "SELECT sum(order_detail.quantity*order_detail.price) as chenes, orders.date
FROM order_detail
LEFT JOIN orders ON order_detail.orderid=orders.serial
WHERE date(orders.date) BETWEEN '$datefrom' AND '$dateto'";
mysql_set_charset("UTF8");
$result = @mysql_query($qry);
while ($row=mysql_fetch_array($result)){
echo "Sales from ".date("F d Y",strtotime($datefrom))." ";
echo "to ".date("F d Y",strtotime($dateto))." are a total of ";
echo "₱".number_format($row['chenes'],2);
}
and here is my code for displaying the individual prices for each orderid.
$AAA = "SELECT order_detail.quantity,order_detail.price,order_detail.orderid, orders.date
FROM order_detail
LEFT JOIN orders ON order_detail.orderid=orders.serial
WHERE orderid=3";
$BBB=@mysql_query($AAA);
while($CCC=mysql_fetch_array($BBB)){
echo "<br>".$CCC['price']."<br>";
}
It works but so far i have no idea how to automatically display it without having the orderid.
Please help me display the price for each, because so far i have only displayed the total, and what i need now is to display the total and it's break down. i've tried the query above and so far i am stuck. please help . thank you.