我正在进行设施预订申请,该申请允许用户搜索设施,具有给定的设施类型,日期,入住和退房时间。
例如:用户在20-08-2016搜索羽毛球场,并且入住时间是18:00到20:00(退房时间),数据库存在记录是从18:00到20:00,它应该返回"不可用",到目前为止运行良好。 但如果入住时间是18:30,结账时间是19:30,即18:00到20:00之间,则不会显示"不可用"。所以我的问题是,如何使18:00到20:00成为一个插槽,并阻止登记和退房时间之间的时间,以防止它显示不同的结果。
我尝试在PHP中包含此代码,但它不起作用
if($response["time_in"]<$time_in<$response["time_out"])
echo "Not Available";
else if($response["time_in"]<$time_out<$response["time_out"])
echo "Not Available";
这是我的整个search.php文件,用于从数据库中检索数据
Ps:time_in相当于入住时间, time_out相当于退房时间
?php
$con = mysqli_connect("mysql1.000webhost.com" , "a6539091_UD" , "0108981390" , "a6539091_UD") or die(mysql_error());
$venue = $_POST["Venue"];
$facility = $_POST["Facility"];
$date = $_POST["Date"];
$time_in = $_POST["Time_in"];
$time_out = $_POST["Time_out"];
$selectquery = mysqli_prepare($con, "SELECT * FROM SearchAva WHERE (Venue = ? AND Facility = ? AND Date = ? AND Time_in = ? AND Time_out = ?)");
mysqli_stmt_bind_param($selectquery, "sssss", $venue, $facility, $date, $time_in, $time_out);
mysqli_stmt_execute($selectquery);
mysqli_stmt_store_result($selectquery);
mysqli_stmt_bind_result($selectquery, $venue, $facility, $date, $time_in, $time_out);
$response = array();
while(mysqli_stmt_fetch($selectquery)){
$response["venue"] = $venue;
$response["facility"] = $facility;
$response["date"] = $date;
$response["time_in"] = $time_in;
$response["time_out"] = $time_out;
}
if($time_in>$response["time_in"] && $time_in<$response["time_out"])
echo "Not Available";
else if($time_out>$response["time_in"]&& $time_out<$response["time_out"])
echo "Not Available";
echo json_encode($response);
mysqli_stmt_close($selectquery);
mysqli_close($con);
?>