|
|
|
ทำโชวืแบบรายเดือนได้แล้ว แต่อยากรู้ว่าทำไงให้มัน Sum ยอดของเดือนนั้นๆอ่าค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$month = ($_POST[month]);
$year = ($_POST[year]);
$sql = "SELECT orders.odate,
orderdetail.pname,
orderdetail.pprice,
orders.shipprice,
orders.grandtotal
FROM orders,orderdetail
WHERE MONTH(odate) = $month and YEAR(odate) = $year";
$result = mysql_query($sql) or die($sql);
$i = 0; $sum = 0;
while($row = mysql_fetch_array($result)){
$i++;
$sum += floatval($row["pprice"]);
?>
<tr>
<td><center><?php echo $i ?></center></td>
<td><center><?php echo $row["odate"] ?></center></td>
<td><center><?php echo $row["pname"] ?></center></td>
<td><center><?php echo number_format ($row["pprice"])?></center></td>
</tr>
<?php }?>
<tr>
<td colspan="3" align="right">รวมยอดขายทั้งหมด</td>
<td><center><?php echo $sum; ?></center></td>
|
|
|
|
|
Date :
2014-02-05 23:21:52 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|