Jump to content

Query for time slots available


chadpriddle

Recommended Posts

I've searched the forum and can't find an answer to my specific issue.

 

I want to do a query that finds and available time slot that is in 15 minute increments but the appointment might be 30 minutes or an hour so it needs to search the database and see if that amount of time is available and then reserve it.

 

time.png

 

$time_minute = the amount of time each services would take; example 15 minutes, 30 minutes, etc. in the format of SQL time: 00:15:00

$query_new_services = "SELECT * FROM calendar WHERE client_id = '$client_id' AND date = '$services_date' AND (time_end - time_start) >= '$time_minute'";
$result_new_services = mysql_query($query_new_services) or die ("Query failed - Calendar");
$num_of_rows_services = mysql_num_rows($result_new_services);
while($row_calendar=mysql_fetch_assoc($result_new_services))
{
$array_time_start[] = $row_calendar["time_start"];
}
$time_slots = implode(', ',$array_time_start);	

if($num_of_rows_services < 1){
$respond_text = "No available services for $day_text. Please select another day";
} else { 
$respond_text = "Select time: $time_slots";
}

 

I've read about OUTER and INNER JOIN but I don't know if that helps my situation. Also, I'm trying to keep all the data in the database in the time and date format. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/219759-query-for-time-slots-available/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.