|
|
|
หาผลรวมทำยังไงคับ ช่วยหน่อยคับมีรูปด้านใน.....แบบว่าให้แสดงผลรวม ของระยะทางได้อะคับ ช่วยหน่อยคับทุกท่าน.. |
|
|
|
|
|
|
|
แบบว่าให้แสดงผลรวม ของระยะทางได้อะคับ ช่วยหน่อยคับทุกท่าน..
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สรุปรายงาน</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
background-image: url();
}
.style22 {color: #FFFFFF}
-->
</style>
</head>
<body><?php
if($year_round=="")
{
echo "<center>****กรุณาระบุปีงบประมาณ****</center>";
}
else
{
$year_round=$_POST['year_round'];
$department=$_POST['department'];
$drive_name=$_POST['drive_name'];
$car_number=$_POST['car_number'];
//echo "?? ";
$hostname = "localhost"; //?
$user = "root"; //?
$password = "root"; //??
$dbname = "car"; //??
$tblname = "data"; //??
//แก้ไข
/*if($_POST['type_pos'] !="ทั้งหมด"){
$sql ="select * from data, date where data.id_user = date.id_user and date.year_round='$year_round' and date.type_pos='$type_pos'and data.department='$department' group by date.id_user order by name ";
}
else{
$sql ="select * from data, date where data.id_user = date.id_user and data.department='$department' group by date.id_user order by name ";
}
if($_POST['department'] !="ทั้งหมด"){
$sql ="select * from data, date where data.id_user = date.id_user and date.year_round='$year_round' and date.type_pos='$type_pos'and data.department='$department' group by date.id_user order by name ";
}
else{
$sql ="select * from data, date where data.id_user = date.id_user and date.type_pos='$type_pos' group by date.id_user order by name ";
}
*/
print"<font size=2><center>สรุปข้อมูลการใช้รถ</center><br></font> ";
print "<font size=2><center>ปีงบประมาณ $year_round หน่วยงาน $department ผู้ขับ $drive_name</center></font><br><br>";
echo "<table border='1' width=80% align=center>";
print "<table width=1024 align=center border=1>";
print "<tr bgcolor=0066FF>";
print "<td align = center width=3%><font color=ffffff size=2>ลำดับ</font></td>";
print "<td align = center width=7%><font color=ffffff size=2>ปีงบประมาณ</font></td>";
print "<td align = center width=15%><font color=ffffff size=2>หน่วยงาน</font></td>";
print "<td align = center width=20%><font color=ffffff size=2>สถานที่ไป</font></td>";
print "<td align = center width=7%><font color=ffffff size=2>หมายเลขรถ</font></td>";
print "<td align = center width=10%><font color=ffffff size=2>วันที่ใช้รถ</font></td>";
print "<td align = center width=10%><font color=ffffff size=2>วันที่สิ้นสุดการใช้</font></td>";
print "<td align = center width=10%><font color=ffffff size=2>ชื่อผู้ขับ</font></td>";
print "<td align = center width=7%><font color=ffffff size=2>ระยะทางทั้งหมด(กม.)</font></td>";
print "<td align = center wdth=3%><font color=ffffff size=2>ลบ</font></td>";
print "</tr>";
//echo "?? ";
$hostname = "localhost"; //?
$user = "root"; //?
$password = "root"; //??
$dbname = "car"; //??
$tblname = "data"; //??
if ($_POST['drive_name'] !=='ทั้งหมด' and $_POST['department'] !=='ทั้งหมด' and $_POST['car_number'] !=='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where drive_name='$drive_name' and department='$department' and car_number='$car_number' and start_mile!='0' ";}
/* elseif ($_POST['drive_name'] ='ทั้งหมด' and $_POST['department'] ='ทั้งหมด' and $_POST['car_number'] !='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where car_number='$car_number' and start_mile!='0'";}
*/
elseif ($_POST['drive_name'] !=='ทั้งหมด' and $_POST['department'] =='ทั้งหมด' and $_POST['car_number'] =='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where drive_name='$drive_name' and start_mile!='0'";}
elseif ($_POST['drive_name'] =='ทั้งหมด' and $_POST['department'] !=='ทั้งหมด' and $_POST['car_number'] =='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where department='$department' and start_mile!='0'";}
elseif ($_POST['drive_name'] =='ทั้งหมด' and $_POST['department'] =='ทั้งหมด' and $_POST['car_number'] !=='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where car_number='$car_number' and start_mile!='0'";}
elseif ($_POST['drive_name'] !=='ทั้งหมด' and $_POST['department'] !=='ทั้งหมด' and $_POST['car_number'] =='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where department='$department' and drive_name='$drive_name' and start_mile!='0'";}
elseif ($_POST['drive_name'] !=='ทั้งหมด' and $_POST['department'] =='ทั้งหมด' and $_POST['car_number'] !=='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where car_number='$car_number' and drive_name='$drive_name' and start_mile!='0'";}
elseif ($_POST['drive_name'] =='ทั้งหมด' and $_POST['department'] !=='ทั้งหมด' and $_POST['car_number'] !=='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where car_number='$car_number' and department='$department' and start_mile!='0'";}
else
{ $sql ="SELECT * FROM data where year_round='$year_round'and start_mile!='0'
";}
//echo"$sql ";
//echo $sql;
// ติด ต่อ database
mysql_connect($hostname, $user, $password) or die("cannot connect");
// เลือก database
mysql_select_db($dbname) or die("cannot select db");
// ทำให้ อ่านภาษาไทยได้ใน utf8
mysql_query("SET NAMES utf8");
$result = mysql_query($sql);
$row_number = mysql_num_rows($result); // หาจำนวน แถว ข้อมูลที่ ค้นหาได้
$id=1;
if($row_number > 0){
while($record = mysql_fetch_array($result)){
$record1=$record["id"];
$record2=$record["year_round"];
$record3=$record["department"];
$record4=$record["location"];
$record5=$record["start_day"];
$record6=$record["start_month"];
$record7=$record["start_year"];
$record8=$record["end_day"];
$record9=$record["end_month"];
$record10=$record["end_year"];
$record11=$record["car_number"];
$record12=$record["drive_name"];
$record13=$record["total_mile"];
?>
<tr bgcolor="#F3F7FE" bordercolor="#0033FF">
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:1%;"><a><?=$id?></a></td>
<td style="font:Arial, Helvetica, sans-serif; color: #00008B; text-align:center; font-size:12px; width:4%;"><?=$record2?></td>
<td style="font:Arial, Helvetica, sans-serif; color: #993399; text-align:left; font-size:12px; width:4%;"><b><?=$record3?></b></td>
<td style="font:Arial, Helvetica, sans-serif; color: #00008B; text-align:left; font-size:12px; width:4%;"><?=$record4?></td>
<td style="font:Arial, Helvetica, sans-serif; color: #00008B; text-align:center; font-size:12px; width:4%;"><?=$record11?></td>
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:5%;"><a><?=$record5?> <?=$record6?> <?=$record7?></a></td>
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:5%;"><a><?=$record8?> <?=$record9?> <?=$record10?></a></td>
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:3%;"><a><?=$record12?></a></td>
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:3%;"><a><?=$record13?></a></td>
<td style="font:tahoma; color:#00008B; text-align:center; font-size:12px; width:5%;"><a href="delete.php?id=<?=$record1?>" runat="server" onclick="return submit2_onclick()">ลบ</a></td>
</tr>
<?php
$id++;
}
}
//ไม่มีค่าส่งมา
echo "</table>";
print"</table><br><br>";
mysql_close();
}
?>
</tr>
<span class="style22"></span>
</body>
</html>
Tag : PHP
|
ประวัติการแก้ไข 2013-03-29 15:52:49 2013-03-29 15:54:20
|
|
|
|
|
Date :
2013-03-29 15:51:41 |
By :
au_mutd |
View :
781 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
เพิ่มใน loop while
$sumtotal = $sumtotal+$record13;
echo $sumtotal;
|
|
|
|
|
Date :
2013-03-29 16:20:38 |
By :
GhostLocal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบพระคุณมากคับ...จะลองดูคับ
|
|
|
|
|
Date :
2013-03-29 16:32:50 |
By :
au_mutd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขึ้นแบบนี้คับ 50 100 140
|
|
|
|
|
Date :
2013-03-29 16:35:25 |
By :
au_mutd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่ม
Code (PHP)
$record14 +=$record["total_mile"];
|
|
|
|
|
Date :
2013-03-29 17:56:09 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|