รบกวนช่วยดูให้หน่อยนะคะ
โค้ด: เลือกทั้งหมด
<?
if($_POST["txt_datefrom"] != "" && $_POST["txt_datefrom"] != ""){
$sql = " SELECT p.SalePromotionName , p.StartDate, p.EndDate, SUM(r.AmountAfterDiscount) AS AmountAfterDiscount, COUNT(p.SalePromotionName) AS Count ";
$sql .= " FROM lotusspa.reservation r ";
$sql .= " LEFT JOIN lotusspa.salepromotion p ON p.SalePromotionID = r.SalePromotionID ";
$sql .= " WHERE r.ReserStatus IN (2,3) ";
$sql .= " AND r.ReserDate BETWEEN '".$datefrom."' AND '".$dateto."' ";
$sql .= " GROUP BY p.SalePromotionName ";
$sql .= " ORDER BY Count DESC ";
$result = mysql_query($sql);
$rowcount = mysql_num_rows($result);
if($rowcount != 0){
$_SESSION["pie_sql"] = "";
$_SESSION["pie_sql"] = $sql;
echo "<div align='center'><img src='report_pro_pie'></div>";
}
echo "<table align='center' width='70%' border='1' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td scope='col' class='header'>Name</td>";
echo "<td scope='col' class='header'>Period of time</td>";
echo "<td scope='col' class='header'>Count</td>";
echo "<td scope='col' class='header'>Total</td>";
echo "</tr>";
echo "<tr></tr>";
$totalafterdiscount = 0;
$totalcount = 0;
while($dbarr = mysql_fetch_array($result)){
echo "<tr>";
echo "<td scope='col' class='detail'>
<div align='center'>".$dbarr["SalePromotionName"]."</div></td>";
echo "<td scope='col' class='detail'><div align='center'>".$dbarr["StartDate"]." - ".$dbarr["EndDate"]."</div></td>";
echo "<td scope='col' class='detail'><div align='right'>".number_format($dbarr["Count"])."</div></td>";
echo "<td scope='col' class='detail'><div align='right'>".number_format($dbarr["AmountAfterDiscount"],2)."</div></td>";
echo "</tr>";
$totalafterdiscount += $dbarr["AmountAfterDiscount"];
$totalcount += $dbarr["Count"];
}
echo "<tr>";
echo "<td colspan='2' class='header' align='center'>Revenues</td>";
echo "<td calss='detail'><div align='right'>".number_format($totalcount)."</div></td>";
echo "<td calss='detail'><div align='right'>".number_format($totalafterdiscount,2)."</div></td>";
echo "</tr>";
echo "</table>";
}
?>