<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$objConnect = mysql_connect("localhost","root","admin1234") or die("Error Connect to Database");
$objDB = mysql_select_db("itbookonline");
$strSQL = "SELECT *
FROM tbl_order o, tbl_order_item oi, tbl_product p
WHERE oi.pd_id = p.pd_id and o.od_id = oi.od_id ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="100%" height="40" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
<tr align="center" id="listTableHeader">
<td width="101" align="center">วันที่และเวลา</td>
<td width="41" align="center">ใบสั่งซื้อ</td>
<td width="41" align="center">รหัสสินค้า</td>
<td width="120" align="center">รายการ</td>
<td width="40" align="center">จำนวน</td>
<td width="50" align="center">ราคารวม</td>
</tr>
</table>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
$number1 = $objResult["od_qty"];
$number2 = $objResult["pd_price"];
if ($i%2) {
$class = 'row1';
} else {
$class = 'row2';
}
$i += 1;
?>
<table width="100%" height="40" align="center" cellpadding="2" cellspacing="1" class="text">
<tr class="<?php echo $class; ?>">
<td width="100" align="center"><?php echo $objResult["od_date"];?></td>
<td width="40" align="center"><?php echo $objResult["od_id"];?></td>
<td width="40" align="center"><?php echo $objResult["pd_id"];?></td>
<td width="118" align="center"><?php echo $objResult["pd_name"];?></td>
<td width="43" align="center"><?php echo $objResult["od_qty"];?></td>
<td width="49" align="right"><?php echo number_format( $number1 * $number2 );?></td>
</tr>
</table>
<?php
}
?>
ช่วยแก้ code php หายอดรวมสุทธิของจำนวนสินค้าหน่อยครับ
<?php
$objConnect = mysql_connect("localhost","root","admin1234") or die("Error Connect to Database");
$objDB = mysql_select_db("itbookonline");
$strSQL = "SELECT *
FROM tbl_order o, tbl_order_item oi, tbl_product p
WHERE oi.pd_id = p.pd_id and o.od_id = oi.od_id ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="100%" height="40" border="0" align="center" cellpadding="2" cellspacing="1" class="text">
<tr align="center" id="listTableHeader">
<td width="101" align="center">วันที่และเวลา</td>
<td width="41" align="center">ใบสั่งซื้อ</td>
<td width="41" align="center">รหัสสินค้า</td>
<td width="120" align="center">รายการ</td>
<td width="40" align="center">จำนวน</td>
<td width="50" align="center">ราคารวม</td>
</tr>
</table>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
$number1 = $objResult["od_qty"];
$number2 = $objResult["pd_price"];
if ($i%2) {
$class = 'row1';
} else {
$class = 'row2';
}
$i += 1;
?>
<table width="100%" height="40" align="center" cellpadding="2" cellspacing="1" class="text">
<tr class="<?php echo $class; ?>">
<td width="100" align="center"><?php echo $objResult["od_date"];?></td>
<td width="40" align="center"><?php echo $objResult["od_id"];?></td>
<td width="40" align="center"><?php echo $objResult["pd_id"];?></td>
<td width="118" align="center"><?php echo $objResult["pd_name"];?></td>
<td width="43" align="center"><?php echo $objResult["od_qty"];?></td>
<td width="49" align="right"><?php echo number_format( $number1 * $number2 );?></td>
</tr>
</table>
<?php
}
?>