I am trying to make a selection box for a web page that will only display available appointment dates based on the start and end times of available scheduled. Each of the appointments are in 2 hour time frames of 4-6, 6-8, or 8-10. All data is being pulled from 2 tables appointments and schedules. The issue I'm having is the final if statement is supposed to display the date if there is an available time slot, but instead the web page is just blank. I've tried erasing parts of it to see where the issue is specifically but nothing seems to work. I'm assuming there is some kind of syntax error but I'm not understanding what it is. Any help on this problem is greatly appreciated.
<select name="date">
<?php foreach($appointments as $appointment){
$start_time = $appointment["start_time"];
$end_time = $appointment["end_time"];
$times_array = array(
"4-6" => "",
"6-8" => "",
"8-10" => ""
);
foreach($schedules as $schedule){
if($appointment["available_date"] == $schedule["SS_DATE"]){
if($schedule["SS_TIME"] == "04:00:00"){ $times_array["4-6"] = "scheduled";}
elseif($schedule["SS_TIME"] == "06:00:00"){ $times_array["6-8"] = "scheduled";}
elseif($schedule["SS_TIME"] == "08:00:00"){ $times_array["8-10"] = "scheduled";}
}
}
if(($start_time == "04:00:00") && ($end_time == "06:00:00") && ($times_array["4-6"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
elseif(($start_time == "06:00:00") && ($end_time == "08:00:00") && ($times_array["6-8"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
elseif(($start_time == "08:00:00") && ($end_time == "10:00:00") && ($times_array["8-10"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
elseif(($start_time == "04:00:00") && ($end_time == "08:00:00") && ($times_array["4-6"] == NULL) && ($times_array["6-8"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
elseif(($start_time == "06:00:00") && ($end_time == "10:00:00") && ($times_array["6-8"] == NULL) && ($times_array["8-10"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
elseif(($start_time == "04:00:00") && ($end_time == "10:00:00") && ($times_array["4-6"] == NULL) && ($times_array["6-8"] == NULL) && ($times_array["8-10"] == NULL)){?>
<option value="<?php echo $appointment["available_date"]?>"><?php echo $appointment["available_date"]?></option><?php}
} ?>
</select>