|
 |
|
ผมทำระบบสั่งซื้อสินค้าครับ ติดอยู่ที่เดียวคือราคารวมสินค้ามันไม่ยอมแสดงครับช่วยดูให้ที |
|
 |
|
|
 |
 |
|

ตามรูปนี้ครับ
Code (PHP)
$sqlR = "select * from tb_orders where cus_id ='$_GET[cus_id]'";
$res = mysql_db_query($db,$sql)or die($sqlR);
while($rec = mysql_fetch_array($res)){ //หาออเดอร์ทั้งหมดของลูกค้า
?>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse; border: 1px dotted #008000">
<tr>
<th colspan="5" align="center" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col"><h3>Temporary orders</th>
</tr>
<tr>
<th colspan="5" align="left" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col"></th>
</tr>
<tr>
<th bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col" align="left">Order_number : <?=$record[order_id]?></th>
<th colspan="4" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col">Order_date : <?=$record[order_date]?></th>
</tr>
<tr>
<th width="289" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col"><font color="#000080"></font><font color="#000080">Name</font></th>
<th width="100" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col"><font color="#000080">Price</font></th>
<th width="55" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col">
<font color="#000080"><center>
Num
</center></font></th>
<th colspan="2" bgcolor="#FFFFCC" style="border: 1px dotted #008000" scope="col">
<font color="#000080"><center>
<font color="#000080">Sum</font>
</center></font></th>
</tr><?
$sqlQ = "select *
from tb_product as p,
tb_order_dt as ot
where p.prod_id = ot.prod_id
and ot.order_id = '$rec[order_id]'
order by ot.orderdt_id asc";
$resultQ = mysql_db_query($db,$sqlQ)or die($sqlQ);
while($recordQ = mysql_fetch_array($resultQ)){ //หาข้อมูลสินค้าที่ตรงกับรหัสสินค้าจากตาราง tb_order_dt
?>
<tr><? if($resultQ[prod_prce2] != 0){ // ถ้าราคาสินค้าราคาสมาชิกไม่เท่ากับ0 ?>
<td width="550" align="left" bgcolor="#FFFFFF" style="border: 1px dotted #008000"> <h4 class="style1"> <? echo $recordQ['prod_name_en']; ?> </h4></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000"><h4 class="style2"> <? echo number_format($recordQ['prod_price2'],2,'.',','); ?> </h4></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000">
<h4><? echo $recordQ['orderdt_qty']; ?></h4>
</font></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000"><h4 class="style2"> <? echo number_format($recordQ['orderdt_qty'] * $recordQ['prod_price2'],2,'.',','); ?> </h4></td>
<? $total[$recordQ[order_id]] += $recordQ['orderdt_qty'] * $recordQ['prod_price2'];?>
<? }else{?>
<td align="left" bgcolor="#FFFFFF" style="border: 1px dotted #008000"> <h4 class="style1"> <? echo $recordQ['prod_name_en']; ?> </h4></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000"><h4 class="style2"> <? echo number_format($recordQ['prod_price'],2,'.',','); ?> </h4></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000">
<h4><? echo $recordQ['orderdt_qty']; ?></h4>
</font></td>
<td align="center" bgcolor="#FFFFFF" style="border: 1px dotted #008000"><h4 class="style2"> <? echo number_format($recordQ['orderdt_qty'] * $recordQ['prod_price'],2,'.',','); ?> </h4></td>
<? $total[$recordQ[order_id]] += $recordQ['orderdt_qty'] * $recordQ['prod_price'];?>//ตรวจสอบราคา แล้วเก็บค่า
<? } ?>
</tr>
<? }?>
<tr bgcolor="#CCCCCC" id="total">
<td style="border: 1px dotted #008000" colspan="2" align="left">
<h3><b><font color="#008000"> Total price</font></b></h3></td>
<td style="border: 1px dotted #008000" colspan="2">
<h3 align="right"><b><font color="#008000"><? echo number_format($total[$recordQ['order_id']],2,'.',','); $cart = $total[$record[order_id]] ;?> Baht</font></b></h3></td>
</tr>
</table><br><br>
<? } ?>
<? }?>
ราคาสินค้ามี 2 อย่างครับ ราคาสมาชิก และราคาทั่วไป
$recordQ['prod_price'] คือราคาทั่วไป
$recordQ['prod_price2'] คือราคาสมาชิก
ปัญหาอยู่ที่ $total[$recordQ['order_id']] ไม่แสดงครับ
Tag : PHP, MySQL, DB2, CakePHP

|
|
 |
 |
 |
 |
Date :
2011-08-30 21:26:37 |
By :
golderboy |
View :
831 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 05
|