chadpriddle Posted November 25, 2010 Share Posted November 25, 2010 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_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 More sharing options...
fenway Posted November 25, 2010 Share Posted November 25, 2010 Sorry, I don't follow. Link to comment https://forums.phpfreaks.com/topic/219759-query-for-time-slots-available/#findComment-1139573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.