<?php
$db=new mysqli( ...);
$sql = '
select * from slots as s
where not exists(
select * from booking
where s.id=slot_id
and (
(start_date between '."'".$_POST['date_start']."' and '".$_POST['date_end']."')".'
or
(end_date between '."'".$_POST['date_start']."' and '".$_POST['date_end']."')
)
)"
/*
สร้าง options จาก result ที่ได้
*/
echo $options_html;
<?php
require_once('Connections/connection.php');
$sql = '
select * from space as s
where not exists(
select * from bookingdetail
where s.S_ID=space_S_ID
and (
(Datestart between '."'".$_POST['date_start']."' and '".$_POST['date_end']."')".'
or
(Dateend between '."'".$_POST['date_start']."' and '".$_POST['date_end']."')
)
)";
$result = mysqli_query($dbcon,$sql) or die("Error:" . mysqli_error());
while($row = mysqli_fetch_array($result))
{
echo"<option value='$row[0]'>".$row["Name_S"].", ".$row["Name_Bulid"].", ".$row["Name_F"]."</option>";
}
?>