|
 |
|
พี่ๆช่วยแนะนำวิธีหาผลรวมหน่อยครับคือผมหาแบบแยกได้ และผมต้องการแบบสรุปยอดรวมผมไม่ทราบวิธีทำครับช่วยแนะทีครับผม |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php while (strtotime($stdate) <= strtotime($_GET['endate'])) {
$where=' where orders_date="'.$stdate.'" ';
$query = sprintf('select * from orders %s',$where);
$result = mysqli_query($con,$query);
if (mysqli_num_rows($result)>0) {
?>
<table class="table table-bordered">
<p>วันที่ : <?php echo thaidate($stdate); ?></p>
<thead>
<tr>
<th>#</th>
<th>ชื่อลูกค้า</th>
<th>การรับสินค้า</th>
<th>รวมเป็นเงิน</th>
<th>สถานะ</th>
</tr>
</thead>
<?php
$where=' where orders_date="'.$stdate.'" ';
$query = sprintf('select * from orders %s',$where);
$result = mysqli_query($con,$query);
if (mysqli_num_rows($result)>0)
{
$val='';
for ($i=1;$i<=mysqli_num_rows($result);$i++) {
$rs = mysqli_fetch_array($result);
$query2 = 'select * from orders_detail where orders_id='.$rs['orders_id'];
$result2 = mysqli_query($con,$query2);
for ($j=1;$j<=mysqli_num_rows($result2);$j++) {
$rs2 = mysqli_fetch_array($result2);
$query3 = 'select * from product where pro_no="'.$rs2['pro_no'].'"';
$result3 = mysqli_query($con,$query3);
$rs3 = mysqli_fetch_array($result3);
$sum='';
$x +=$rs2['pro_amount'] * $rs3['pro_price'];
$sum +=$rs2['pro_amount'] * $rs3['pro_price'];
$val +=$rs2['pro_amount'] * $rs3['pro_price'];
}
$query4 = sprintf('select * from branch where br_id=%s',$rs['branch_id']);
$result4 = mysqli_query($con,$query4);
$rs4 = mysqli_fetch_array($result4);
?>
<tbody>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $rs['cus_name']; ?></td>
<td><?php echo 'รับที่ '.$rs4['br_name'].'<br> วันที่ : '.thaidate($rs['rec_date']).' - '.$rs['rec_time']; ?></td>
<td><?php echo number_format($sum,2); ?></td>
<td>
<?php if ($rs['orders_status']==1) {echo 'ยังไม่ชำระเงิน';}
else if ($rs['orders_status']==2) { echo 'รอการตรวจสอบ'; }
else if ($rs['orders_status']==3) { echo 'รอจัดส่งสินค้า'; }
else {echo 'รับสินค้าเรียบร้อย';} ?>
</td>
</tr>
<?php }} ?>
</tbody>
<tr>
<td colspan="5"><h5 class="pull-right">จำนวน <?php echo $i-1; ?> รายการ <br><br>รวม <?php echo number_format($val,2); ?> บาท</h5></td>
</tr>
<?php } $stdate = date ("Y-m-d", strtotime("+1 day", strtotime($stdate)));}?>
<tr>
<td colspan="5"><h5 class="text-right">
รวมทั้งหมด <?php echo $i; ?> รายการ<br><br>
ราคารวม <?php $t = $x*7/100 ;
$c = $x + $t; echo number_format($x,2);?> บาท<br><br>
VAT 7% <?php echo number_format($t,2); ?> บาท<br><br>
รวมทั้งหมด <?php echo number_format($c,2); ?> บาท </h5>
</td>
</tr>
</table>

Tag : PHP

|
ประวัติการแก้ไข 2016-09-16 14:22:09
|
 |
 |
 |
 |
Date :
2016-09-16 14:20:43 |
By :
DisconnectOver |
View :
718 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาทุกตัวแปรมา sum ครับ
|
 |
 |
 |
 |
Date :
2016-09-16 15:24:22 |
By :
stepartz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประมาณไหนหรอครับ
|
 |
 |
 |
 |
Date :
2016-09-16 15:32:00 |
By :
DisconnectOver |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$sum = $x + $sum + $val
เอาตัวแปรที่ต้องการจะsumมาครับ
|
 |
 |
 |
 |
Date :
2016-09-16 16:20:23 |
By :
stepartz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ได้แล้วครับผม
|
 |
 |
 |
 |
Date :
2016-09-19 15:00:15 |
By :
DisconnectOver |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2016-09-20 11:09:40 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|