 <?php
session_start();
$cmpmid=$_SESSION['linkarisecmpmid'];
include('connect.php');
error_reporting(0);



if(isset($_POST["dcontact17"]) && !empty($_POST["dcontact17"])){
    //Get all city data
   
$spotmid = $_POST['dcontact17'];

date_default_timezone_set("Asia/Singapore");
				$mdate1= date('Y-m-d H:i:s');
				$mdate= date('Y-m-d');


$eve="SELECT * FROM res_availibility_detail WHERE availabledate>='$mdate' and spotmid=$spotmid and cmpmid='$cmpmid' and availablestatus='Available' GROUP BY spotmid,availabledate";
    $re = mysqli_query($conn, $eve);
//echo '<option value="'.$eve.'">'.$eve.'</option>';
    //Count total number of rows
    if(mysqli_num_rows($re) > 0)
{
	

        while($rt = mysqli_fetch_assoc($re)){
				$availabledate=date("d-m-Y",strtotime($rt['availabledate']));	
			$eve1 = "select * from res_slots_master where cmpmid='$cmpmid' and slotmid in (select slotmid from res_availibility_detail where spotmid=$spotmid AND availabledate = '$rt[availabledate]' and availablestatus='Available')";

																			$re1 = mysqli_query($conn, $eve1);
																			//echo '<option value="'.$eve1.'">'.$eve1.'</option>';
																			while($rt1 = mysqli_fetch_assoc($re1))

																			{											
																				
																				$slotmid=$rt1['slotmid'];
																				$slotname=$rt1['slotname'];
																			
																				$starttime=date("H:i", strtotime($rt1['slotstarttime']));
																				$endtime=date("H:i", strtotime($rt1['slotendtime']));
																				
																				echo "<option value='$slotmid'>$availabledate  $slotname ($starttime-$endtime)</option>";
																				 
																			}
       

        }
    }else{
        echo '<option value="0">No Data Found</option>';
    }
}
?>