 |
|
ช่วยดูให้หน่อยค่ะเวลาเลือกัวนที่และเวลาจอง ทำไมมันขึ้นแต่มีคนจองไปแล้วค่ะ ทั้งๆที่ไม่มีคนจอง ต้องแก้ตรงไหนค่ะ

Code (reserv_roomsave)
<?php
session_start();
$ses_userID = $_SESSION["ses_userID"];
?>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<?php
include("config.php");
$subject=$_REQUEST["subject"];
$now = date("Y-m-d ");
$strdate=explode("-",$_REQUEST["strdate"]);
$enddate=explode("-",$_REQUEST["enddate"]);
$timeIn=$_REQUEST["timeIn1"].':'.$_REQUEST["timeIn2"];
$timeOut=$_REQUEST["timeOut1"].':'.$_REQUEST["timeOut2"];
$classID=$_REQUEST["classID"];
$departmentsID = $_REQUEST['parent_dep'];
$branchID=$_REQUEST["sub_branch"];
$amount=$_REQUEST["amount"];
$equipment = $_REQUEST["equipment"];
$detail=$_REQUEST["detail"];
$sql = "SELECT * FROM reservroom WHERE ((strdate between '".$_REQUEST["timeIn"]."' and '".$_REQUEST["timeOut"]."') or ";
$sql.= " (enddate between '".$_REQUEST["timeIn"]."' and '".$_REQUEST["timeOut"]."')) and ";
$sql.= " ((timeIn between '".$timeIn."' and '".$timeOut."') or ";
$sql.= " (timeOut between '".$timeIn."' and '".$timeOut."')) ";
$result=mysql_query($sql);
$num_rows=mysql_num_rows($result);
if($num_rows>1)
{
echo "<script>alert('เวลาดังกล่าว มีคนจองไปแล้ว')</script>";
}
else
{
$sql="INSERT INTO reservroom(serviceID,subject,dateSave,strdate,enddate,timeIn,timeOut,userID,classID,departmentsID,branchID,amount,equipment,detail)";
$sql.="VALUES ('','$subject','$now','".$strdate[2]."-".$strdate[1]."-".$strdate[0]."','".$enddate[2]."-".$enddate[1]."-".$enddate[0]."','$timeIn','$timeOut','$ses_userID','$classID','$departmentsID','$branchID','$amount','$equipment','$detail')";
mysql_query($sql,$conn)
or die("ไม่สามารถเพิ่มข้อมูลลงสู่ตาราง reservroom ได้".mysql_error());
//echo "การเพิ่มข้อมูลสมบูรณ์";
echo "<meta http-equiv=\"refresh\" content=\"1;URL=user_home.php\">";
mysql_close($conn);
}
?>
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2014-03-09 22:11:20 |
By :
june_191 |
View :
647 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |