$strSQL = "SELECT
* FROM `booking`
WHERE ((sdate between '".$sdate."' and '".$edate."') or ";
$strSQL .= " (edate between '".$sdate."' and '".$edate."')) and ";
$strSQL .= " ((stime between '".$stime."' and '".$etime."') or ";
$strSQL .= " (etime between '".$stime."' and '".$etime."')) and room = '".$room."'";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<script>alert('ห้องนี้มีผู้ใช้งานแล้วกรุณาตรวจสอบอีกครั้ง!');history.back();</script>";
}