Hi id like to search for available apartments within a specific date (user specified)
MySQL system_apartment table:
MySQL system_booking table:
This is the current code for my php process
if($_POST)
{
$user_checkin = test_input($_POST['checkin']);
$user_checkout = test_input($_POST['checkout']);
$user_noofpeople = test_input($_POST['noofpeople']);
$user_roomtype = test_input($_POST['roomtype']);
try
{
$stmt = $db_con->prepare("
SELECT r.*
FROM system_apartment AS r
WHERE r.apartment_id
NOT IN
(
SELECT b.booking_apartmentid
FROM system_booking AS b
WHERE (b.booking_date_checkout >= $user_checkin AND b.booking_date_checkin <= $user_checkout)
OR (b.booking_date_checkout <= $user_checkin AND b.booking_date_checkin >= $user_checkout)
)
");
$stmt->execute();
$count = $stmt->fetchAll();
$count = count($count);
if($count==0){
echo "working"; // not available
}
else{
echo "not working"; // not available
}
}
catch(PDOException $e){
echo $e->getMessage();
}
I would very much appreciate it if anyone can tell me where I'm going wrong!