<table width="76%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="4" align="center"><h1>สรุปการขายประจำวันที่ <?=$daten;?></h1><br>
<FORM name=searchDate action=showsell_date.php method="post"> ค้นหายอดขายตาม..
<select name="ref_date_id">
<option value="0">วันที่ทั้งหมด</option>
<?
$sqlc="SELECT * FROM tb_order GROUP BY od_date ORDER BY od_date DESC";
$resultc = mysql_query($sqlc);
while($dbarr_cat=mysql_fetch_array($resultc)) {
echo "<option value=" . $dbarr_cat['selldate'] . ">" . $dbarr_cat['selldate'] . "</option>";
}
?>
</select>
<INPUT type=submit value="ค้นหา" name=BtnSearch>
</FORM>
</td>
</tr>
<tr bgcolor="#FFFF66">
<td width="15%" height="30" align="center"><b>รหัสพระเครื่อง</b></td>
<td width="55%" height="30" align="center"><b>รายการพระเครื่อง</b></td>
<td width="15%" height="30" align="center"><b>จำนวนพระเครื่อง</b></td>
<td width="15%" height="30" align="center"><b>จำนวนเงิน</b></td>
</tr>
<?
if ($_REQUEST['ref_date_id']=="") { $result_cat=mysql_query ("SELECT tb_product.pd_id, tb_product.pd_name,tb_category.cg_name,tb_orderview.odb_price,
tb_orderview.odv_amount, sum(tb_orderview.odv_amount) AS SUMQTY FROM tb_orderview,
tb_order , tb_product ,tb_category WHERE (tb_order.od_status<>'1') AND (tb_order.od_status<>'2') AND (tb_order.od_status<>'3')
AND (tb_order.od_id= tb_orderview.od_id) AND (tb_product.cg_id= tb_category.cg_id)
and (tb_orderview.pd_id= tb_product.pd_id) and (tb_order.od_date='$datenow')
GROUP BY tb_orderview.pd_id ORDER BY tb_product.pd_id")or die (mysql_error());
}
else if ($_REQUEST['ref_date_id']=="0") { $result_cat=mysql_query ("SELECT tb_product.pd_id, tb_product.pd_name,tb_category.cg_name,tb_orderview.odb_price,
tb_orderview.odv_amount, sum(tb_orderview.odv_amount) AS SUMQTY FROM tb_orderview,
tb_order , tb_product ,tb_category WHERE (tb_order.od_status<>'1') AND (tb_order.od_status<>'2') AND (tb_order.od_status<>'3')
AND (tb_order.od_id= tb_orderview.od_id) AND (tb_product.cg_id= tb_category.cg_id)
AND(tb_orderview.pd_id= tb_product.pd_id) GROUP BY tb_orderview.pd_id ORDER BY tb_product.pd_id") or die (mysql_error());
} else { $result_cat = mysql_query("SELECT tb_product.pd_id, tb_product.pd_name,tb_category.cg_name,tb_orderview.odb_price,
tb_orderview.odv_amount, sum(tb_orderview.odv_amount) AS SUMQTY FROM tb_orderview,
tb_order , tb_product ,tb_category WHERE (tb_order.od_status<>'1') AND (tb_order.od_status<>'2') AND (tb_order.od_status<>'3')
AND (tb_order.od_id= tb_orderview.od_id) AND (tb_product.cg_id= tb_category.cg_id)
AND (tb_orderview.pd_id= tb_product.pd_id) and (tb_order.od_date='$_REQUES[ref_date_id]')
GROUP BY tb_orderview.pd_id ORDER BY tb_product.pd_id") or die (mysql_error());
}
$totalrecord=mysql_num_rows($result_cat);
while ($dbarr_cat = mysql_fetch_array($result_cat)) {