|
|
|
ช่วยดูโค๊ดหาราคาทุนรวมให้หน่อยค่ะ คำนวณถูกแต่ลงดาต้าเบสผิด |
|
|
|
|
|
|
|
ช่วยดูโค๊ดหาราคาทุนรวมให้หน่อยค่ะ คำนวณถูกแต่ลงดาต้าเบสผิด มันต้องเขียนวนอาเรย์ยังไงคะให้เป็นลำดับ
Code (PHP)
<table width="879" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#666666">
<tr>
<td width="47" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">ลำดับ</span></td>
<td width="83" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">รหัสวัตถุดิบ</span></td>
<td width="226" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">ชื่อวัตถุดิบ</span></td>
<td width="97" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">ประเภทวัตถุดิบ</span></td>
<td width="89" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">จำนวนสั่งซื้อ</span></td>
<td width="101" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">จำนวนที่รับ</span></td>
<td width="107" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">ราคาทุนรวม</span></td>
<td width="30" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">หน่วย</span></td>
<td width="30" align="center" bordercolor="#999999" bgcolor="#CCE6F2"><span class="style16">ราคารวม</span></td>
</tr>
<?
$sql1 = "SELECT distinct material.m_id,ordermat.ormat_id,material.m_name,ordermat_detail.ormat_qty,material.m_cost,ordermat_detail.ormatdetail_id,material.m_unitsale,material_type.mt_name
FROM ordermat_detail, ordermat , material , material_type
WHERE ordermat_detail.ormat_id = ordermat.ormat_id
AND ordermat_detail.m_id = material.m_id
AND material.mt_id = material_type.mt_id
AND ordermat.ormat_id ='$id'
ORDER BY ordermat_detail.ormatdetail_id";
$result1 = mysql_query($sql1);
$n=0;
while($read1 = mysql_fetch_array($result1)){
$n++;
?>
<tr>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16"><?=$n;?></span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16"><?=$read1['m_id'];?></span></td>
<input type="hidden" name="mat[]" value="<?=$read1['m_id'];?>"/>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16"><?=$read1['m_name'];?></span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16"><?=$read1['mt_name'];?></span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16"><?=$read1['ormat_qty'];?></span></td>
<input type="hidden" name="amountt[]" id="amountt<?=$n?>" value="<?=$read['ormat_qty'];?>" />
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16">
<input size="7" type="text" name="receive_amt[]" id="amt<?=$n?>" value="<?=$read1['ormat_qty'];?>"/>
</span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF">
<input name="price[]" type="text" value="<?=$read1['m_cost']?>" size="15"/></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16">
<?=$read1['m_unitsale'];?>
</span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><? echo number_format($read1['ormat_qty']*$read1['m_cost'],2)?></td>
</tr>
<? $total = ($read1['ormat_qty']*$read1['m_cost'])+$total; ?>
<? } ?>
<tr>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"> </td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"> </td>
<td colspan="6" align="right" bordercolor="#999999" bgcolor="#FFFFFF"><span class="style16">รวมราคาทั้งสิ้น</span></td>
<td align="center" bordercolor="#999999" bgcolor="#FFFFFF"><?=number_format($total,2);?></td>
</tr>
</table>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-09-10 01:40:37 |
By :
tiktok16 |
View :
650 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา code วางใส่ tag PHP Code ด้วยครับ แบบนี้ดูยาก
|
|
|
|
|
Date :
2013-09-10 08:32:19 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|