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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.