SELECT * FROM `booking` WHERE ((sdate between '2013-05-28T07:00:00' and '2013-05-28T16:00:00') or (edate between '2013-05-28T07:00:00' and '2013-05-28T16:00:00')) and room = 'ศูนย์ฝึกอบรมคอมพิวเตอร์สำนักการศึกษา'
SELECT * FROM booking WHERE r_id = '".$room."' and ((sdate between '".$sdate."' and '".$edate."') or (edate between '".$sdate."' and '".$edate."') )
วันที่กับเวลา
Code (PHP)
SELECT * FROM booking WHERE r_id = '".$room."' and ((sdate between '".$sdate."' and '".$edate."') or (edate between '".$sdate."' and '".$edate."') )and ((stime between '".$stime."' and '".$etime."') or (etime between '".$stime."' and '".$etime."'))
Date :
2013-05-10 10:17:35
By :
white31969
No. 8
Guest
Code (PHP)
$id=$_POST['txtm_id'];
$sdate=$_POST['date1'].' '.$_POST['hour1'].':'.$_POST["min1"].':00';
$edate=$_POST['date2'].' '.$_POST['hour2'].':'.$_POST["min2"].':59';
$room=$_POST['txtroom'];
$detail=$_POST['txtdetail'];
$strSQL = "SELECT
* FROM `booking`
WHERE ((sdate between '".$sdate."' and '".$edate."') or ";
$strSQL .= " (edate between '".$sdate."' and '".$edate."')) and ";
$strSQL .= "room = '".$room."'";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<script>alert('ห้องนี้มีผู้ใช้งานแล้วกรุณาตรวจสอบอีกครั้ง!');history.back();</script>";
}
SELECT * FROM booking WHERE r_id = '".$room."'
AND
(
(sdate between '".$sdate."' AND '".$edate."') OR (edate between '".$sdate."' AND '".$edate."')
)
AND
(
('".$stime."' BETWEEN stime AND etime) OR ('".$etime."' BETWEEN stime AND etime )
)
ย้ายตำแหน่งการเช็กเวลาครับ
จากเดิม stime between '".$stime."' and '".$etime."' เปลี่ยนเป็น '".$stime."' BETWEEN stime AND etime
และ etime between '".$stime."' and '".$etime." เปลี่ยนเป็น '".$etime."' BETWEEN stime AND etim
SELECT * FROM booking WHERE r_id = '".$room."'
AND
(
(sdate between '".$sdate."' AND '".$edate."') OR (edate between '".$sdate."' AND '".$edate."')
)
AND
(
('".$stime."' BETWEEN stime AND etime) OR ('".$etime."' BETWEEN stime AND etime )
OR (stime between '".$stime."' and '".$etime."') OR (etime between '".$stime."' and '".$etime."')
)
$strSQL = "SELECT * FROM booking WHERE r_id = '".$room."'
AND
(
(sdate between '".$sdate."' AND '".$edate."') OR (edate between '".$sdate."' AND '".$edate."') or
('".$sdate."' between sdate AND edate) OR ('".$edate."' between sdate AND edate)
)
AND
(
('".$stime."' BETWEEN stime AND etime) OR ('".$etime."' BETWEEN stime AND etime )
OR (stime between '".$stime."' and '".$etime."') OR (etime between '".$stime."' and '".$etime."')
)
";