Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอคำแนะนำครับ ต้องการผลบวก (แนวตั้ง) ของ field Labour ต้องเขียน code อย่างไรครับ



 

ขอคำแนะนำครับ ต้องการผลบวก (แนวตั้ง) ของ field Labour ต้องเขียน code อย่างไรครับ

 



Topic : 124163



โพสกระทู้ ( 111 )
บทความ ( 0 )



สถานะออฟไลน์




ขอคำแนะนำครับ ต้องการผลบวก (แนวตั้ง) ของ field Labour ต้องเขียน code อย่างไรครับ
ยอดรวมจาก data baseทำได้แล้ว แต่ จะให้รวมยอด (field Labour) ตามรูป ต้องเขียน code อย่างไร ขอบคุณครับ

รูป

ห้นไ

code php(ตัดเอามาเฉพาะช่วงเขียนคำสั่งครับ)



Code (PHP)
<?php


 $sql_show = "select * FROM customer";
	if($_POST['date_start']) {  
		$date_start = $_POST['date_start'];
		$date_stop = $_POST['date_stop']; 
		$sql_show .=" WHERE (reservation_date between '".$_POST['date_start']."' AND '".$_POST['date_stop']."') 
		
		ORDER BY reservation_date ASC";
   }

   $result_show = mysql_query($sql_show) or die(mysql_error());
	$chk_date = false;  
	$chk_sum = 0;
	$total = 0;
	while($rs = mysql_fetch_array($result_show)) {
		$id = $rs["id"];
		$reservation_date = $rs["reservation_date"]; 
		$date = '';
		$chk_total = '';
		
		if ($chk_date <> $reservation_date) {
			$date = $reservation_date;
			
			if ($chk_date <> false) {
				
		$chk_total = '<div class="total">'.number_format($chk_sum).'</div>';
	}
	$chk_sum = 0;
} 
      $edit_class = (trim($remark) == '') ? '' : ' hide';
		$tr_class = '';
		if ($level == '2') {
			$tr_class = ' class="tr2"';
		}
		else if ($level2 == '3') {
			$tr_class = ' class="tr3"';
		}
		echo '<tr align="center"'.$tr_class.'>';
		?>
        
        
        
<?php echo '<td height="42">'.$date.'</td>';?>

<td><?php echo $rs["fleet"];?></td>
<td><?php echo $rs["destination"];?></td>
<td><?php echo $rs["guest_name"];?></td>
<td><?php echo $rs["amount"];?></td>
<td><? $Labour = ($rs['amount']*15)/100; ?>
  <? echo $Labour; ?></td>

<td><strong><div class="<?php echo $rs["status"];?>"><p class="ex"><?php echo $rs["status"];?></p></div></strong></td>
<td><?php echo $remark;?></td>
<td>
<?php
if($rs["schedule1"] == "" or $rs["schedule2"] == ""){ // ถ้า schedule1 หรือ schedule2 ไม่มีค่า
    echo $rs["schedule1"].$rs["schedule2"];
}else{
    echo $rs["schedule1"]."<hr>".$rs["schedule2"];
}
?>
</td>
<td bgcolor="#999999">
	<div class="text-center<?php echo $edit_class;?>">
		<a href="edit.php?edit_id=<?php echo $id;?>">EDIT</a>
	</div>
</td>

<?php
echo '</tr>';
$chk_date = $reservation_date;
}
?>
<tr class="tr-last">
<td height="36"></td>
<td></td>
<td></td>
<td align="right">Total :</td>
<td align="center"><?php
$query = "SELECT SUM(amount) as s_Total FROM customer 
where reservation_date between '".$_POST['date_start']."' and '".$_POST['date_stop']."'
GROUP BY reservation_date between '".$_POST['date_start']."' and '".$_POST['date_stop']."'";  
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
	echo number_format($row['s_Total']); 
	}?></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

</table>





Tag : PHP









ประวัติการแก้ไข
2016-08-05 17:18:17
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-08-05 17:17:22 By : panya@ots View : 749 Reply : 2
 

 

No. 1



โพสกระทู้ ( 484 )
บทความ ( 3 )



สถานะออฟไลน์


ไม่ได้ลองนะ
Code (PHP)
<?php
 $sql_show = "select * FROM customer";
	if($_POST['date_start']) {  
		$date_start = $_POST['date_start'];
		$date_stop = $_POST['date_stop']; 
		$sql_show .=" WHERE (reservation_date between '".$_POST['date_start']."' AND '".$_POST['date_stop']."') 
		ORDER BY reservation_date ASC";
   }
   $result_show = mysql_query($sql_show) or die(mysql_error());
	$chk_date = false;  
	$chk_sum = 0;
	$total = 0;
	$total2 = 0;
	while($rs = mysql_fetch_array($result_show)) {
		$id = $rs['id'];
		$reservation_date = $rs['reservation_date']; 
		$date = '';
		$chk_total = '';
		if ($chk_date <> $reservation_date) {
			$date = $reservation_date;
			if ($chk_date <> false) {
				$chk_total = '<div class="total">'.number_format($chk_sum).'</div>';
			}
			$chk_sum = 0;
		} 
		$edit_class = (trim($remark) == '') ? '' : ' hide';
		$tr_class = '';
		if ($level == '2') {
			$tr_class = ' class="tr2"';
		}
		else if ($level2 == '3') {
			$tr_class = ' class="tr3"';
		}
		echo '<tr align="center"'.$tr_class.'>';
		$amount = $rs['amount'];
		$total += $amount;
		$Labour = ($amount * 15) / 100;
		$total2 += $Labour;
?>
<?php echo '<td height="42">'.$date.'</td>';?>
<td><?php echo $rs['fleet'];?></td>
<td><?php echo $rs['destination'];?></td>
<td><?php echo $rs['guest_name'];?></td>
<td><?php echo number_format($amount);?></td>
<td><?php echo number_format($Labour);?></td>
<td><strong><div class="<?php echo $rs['status'];?>"><p class="ex"><?php echo $rs['status'];?></p></div></strong></td>
<td><?php echo $remark;?></td>
<td>
<?php
if($rs["schedule1"] == "" or $rs["schedule2"] == ""){ // ถ้า schedule1 หรือ schedule2 ไม่มีค่า
    echo $rs["schedule1"].$rs["schedule2"];
}else{
    echo $rs["schedule1"]."<hr>".$rs["schedule2"];
}
?>
</td>
<td bgcolor="#999999">
	<div class="text-center<?php echo $edit_class;?>">
		<a href="edit.php?edit_id=<?php echo $id;?>">EDIT</a>
	</div>
</td>
<?php
echo '</tr>';
$chk_date = $reservation_date;
}
?>
<tr class="tr-last">
<td height="36"></td>
<td></td>
<td></td>
<td align="right">Total :</td>
<td align="center"><?php echo number_format($total);?></td>
<td align="center"><?php echo number_format($total2);?></td>
<td></td>
<td></td>
<td></td>
<td></td>
</table>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-08-06 08:23:50 By : fossil31
 


 

No. 2



โพสกระทู้ ( 111 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : fossil31 เมื่อวันที่ 2016-08-06 08:23:50
รายละเอียดของการตอบ ::
ขอบคุณมากครับ คุณ fossil
ผมนำไปตัดแปลงเพิ่มเติม ได้ผลดีเลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-08-06 12:23:51 By : panya@ots
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอคำแนะนำครับ ต้องการผลบวก (แนวตั้ง) ของ field Labour ต้องเขียน code อย่างไรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่