|
 |
|
DATE DIFF ครับ รบกวนพี่ ๆ เพื่อน ๆ ช่วยแก้ให้หน่อยครับ วันนี้ต้องส่งแล้ว ร้อนใจมากเลยครับ |
|
 |
|
|
 |
 |
|

ครับคือตอนนี้ดัก ไม่ให้กรอกวันย้อนหลังได้,ให้กรอกหลังวันที่จองวันสุดท้ายได้ แต่ทีติดก็ดังถาพอะครับ ปกติมันจะไม่ให้กรอกวันที่หรือช่วงที่มีการจองไว้แล้วผลการทดสอบ วันที่ 4-6 ทำได้ แต่พอเพิ่มช่วงยาว ๆกรอกวันซ้ำกันได้ จึงรบกวนช่วยหน่อยน่ะครับ
LINK ครับ ลองเล่นดูน่ะครับ เป็นโปรเจควิชา
http://watthai.sobomo.com/Guests/index1.php?temid=000013&module=room&
Code (PHP)
<?
include "connect.php";
function DateDiff($strDate1,$strDate2)
{
return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24
}
$temid=$_GET["tid"];
//print $_GET["tid"];
$rr_id=$_GET["rid"];
//print $rr_id;
$rvt_name=$_POST[rvt_name];
$rvt_lname=$_POST[rvt_lname];
$rvt_tel=$_POST[rvt_tel];
$rvt_addr=$_POST[rvt_addr];
$rvt_number=$_POST[rvt_number];
$rvt_in=$_POST[rvt_in];
$rvt_out=$_POST[rvt_out];
$g_idcard=$_POST[g_idcard];
$filename=$_FILES["rvt_listname"]["name"];
$sqlGetdate="SELECT * FROM reservation where rr_id='$rr_id'";
$dbquery=mysql_query($sqlGetdate);
$result=mysql_fetch_array($dbquery);
$dateCheck=$result['rvt_out'];
//print $dateCheck." ".$rvt_in;
echo "<br>";
//echo "Date Diff = ".DateDiff($dateCheck,$rvt_in)."<br>";
$reCheck=DateDiff($dateCheck,$rvt_in);
$dateNow=date("y-m-d");
//print $dateNow;
//echo "<br>";
$reDateNow=DateDiff($dateNow,$rvt_in);//CheckForOutTo
$reDateNowOut=DateDiff($dateNow,$rvt_out);
$reDateInOut=DateDiff($rvt_in,$rvt_out);
//print $reDateInOut;
if($reDateNow>=0&&$reDateNowOut){
if($reDateInOut>0){
if($reCheck>0){
$sql="select * from reservation ";
$result=mysql_db_query($dbname,$sql);
$num=mysql_num_rows($result);
$sql="insert into reservation (rvt_temid,rr_id,g_idcard,rvt_name,rvt_lname,rvt_tel,rvt_addr,rvt_in,rvt_out)values('$temid','$rr_id','$g_idcard','$rvt_name','$rvt_lname','$rvt_tel','$rvt_addr','$rvt_in','$rvt_out')";
$result=mysql_db_query($dbname,$sql);
//print $sql;
if ($result) {
//$strSQL="select * from room ";
$strSQL = "UPDATE room SET ";
$strSQL .="r_status = 'จองแล้ว'";
$strSQL .=" WHERE r_id = '".$_GET["rid"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery){
$sqlLog="INSERT INTO `logrev` (
`idRoom` ,
`gl_idcard` ,
`nameRev` ,
`dateIn` ,
`dateOut` ,
`idTem`
)
VALUES (
'$rr_id','$g_idcard', '$rvt_name', '$rvt_in' ,'$rvt_out' ,'$temid'
);";
$objQuery = mysql_query($sqlLog);
echo "<h3><script>alert(\"บันทึกการจองเรียบร้อยแล้ว.\");</script></h3>";
//echo "<meta http-equiv='refresh' content='1 ;url=g_look_room.php?&$temid'><br/>" ;
}else{
echo "<h3><script>alert(\"บันทึกการจองไม่เรียบร้อยแล้ว.\");</script></h3>";
//echo "<meta http-equiv='refresh' content='1 ;url=g_look_room.php?=$temid'><br/>" ;
}
} else {
//echo "<h3>ไม่สามารถจองได้</h3>";
echo "<script>alert(\"ไม่สามารถจองได้.\");</script>";
}
mysql_close();
}else{
//print "สามารถจองได้หลังจากวันที่ ".$dateCheck;
echo "<script>alert(\"สามารถจองได้หลังจากวันที่ $dateCheck\");</script>";
}
}else{
//print "กรุณาเลือกวันที่จะออกห้องพักหลักจากวันที่เข้าพัก";
echo "<script>alert(\"กรุณาเลือกวันที่จะออกห้องพักหลักจากวันที่เข้าพัก.\");</script>";
}
}else{
echo "<script>alert(\"กรุณาเลือกวันที่ให้เป็นปัจจุบัน.\");</script>";
}
/*
*/
?>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2010-11-04 13:14:35
|
 |
 |
 |
 |
Date :
2010-11-04 13:12:52 |
By :
itzone |
View :
1030 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค้นในเว็บเลยครับ มีเพียบ ทั้งตัวอย่างด้วยครับ
|
 |
 |
 |
 |
Date :
2010-11-04 15:59:35 |
By :
A1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|