I need help with a PHP / MYSQL question when working with times?

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

Guest
I have been trying for most of today to get this working but cant seem to get it to work properly. Basically I am trying to return all the time slots, (interval's of 15 minutes), available for a customer to make an appointment.

For example;
If employee 1 starts at 10:00:00 and their first appointment is at 10:30:00 until 11:45:00, their lunch start's at 12:00:00 and finishes at 13:00:00 and they are finished work at 18:00:00 i need the user to be given a selection of radio buttons for their appointment to star at 10:00:00 or 10:15:00 or 11:45:00 or 13:00:00 or 13:15:00 or 13:30:00 or 13:45:00 or 14:00:00, etc... but they can't make an appointment which takes longer then 30 minutes at 10:00:00 or more then 15 minutes at 10:15:00 and so on.

I'm really sorry, I have done so many different things to the code today i don't think this chunk of code makes any sense anymore. I hope it makes sense to someone. Any help would be greatly appreciated :)



$result = mysql_query("SELECT time, end_time FROM appointments WHERE employee_id = '$empID' AND day = '$day' AND month = '$month' AND year = '$year'",$con);

$increment = 0;
while($row = mysql_fetch_row($result))
{
$array = array($increment => $row[0]);
$increment = $increment + 1;
print $array[$increment];

$setTime = "10:00:00";
while($setTime != $array[$increment])
{
?>
<input type="radio" name="choice" value="<?php print $setTime; ?>"/>
<?php
$setTime = mysql_query("ADDTIME($setTime, '00:15:00'", $con)
}

}
 
Back
Top