watthehell Posted September 12, 2007 Share Posted September 12, 2007 hi all... This is about a reservation where the user will select a time FROM (hour and minute) and TO (hour and minute), these values are taken from the list box and the date is as selected by the user the problem i am having is For e.g if the user selects 6 am to 7 am on 13th september 2007 Other user cannot save the same time in the next date i.e 14th, 15th, 16th and so on... I did it like this <?php $fromhr=$_REQUEST['from']; // from list box FROM->Hour $tohr=$_REQUEST['to']; //from list box TO->Hour $frommin=$_REQUEST['fromtime']; //from list box From->min $tomin=$_REQUEST['totime']; // from list box TO->min $date = $user_sel_date; // this is the user selected date saves in date field in db //here i checked for the condition for time overlapping and TO time must not be less than FROM time if(($from <$to)) { /* Here in this query i am having confusion how to check for the date value, user must be allowed to save the same time but for separate dates.. can anyone guide me please in this query*/ $que1= "SELECT * FROM user_reservation WHERE (user_reserve_time_end > $from AND user_reserve_time_start < $to)"; $result1 = mysql_query($que1); if (mysql_num_rows($result1)!=0) { $var1=true; $app->error_display_type=2; $app->error("This record overlaps existing time slots"); } else { $var2=true; $que2="insert into voyance_user_reservation values('','".$curruserid."','".$from."','".$to."','".$date."','','')"; $result2=mysql_query($que2); $app->error_display_type=2; $app->error("Time Reserved Successfuly"); } } else { $var3=true; $app->error_display_type=2; $app->error("Start Time Cannot Be Greater Than Or Equal To The End Time"); } ?> thnks... Quote Link to comment https://forums.phpfreaks.com/topic/69010-can-anyone-help-on-this/ Share on other sites More sharing options...
watthehell Posted September 12, 2007 Author Share Posted September 12, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/69010-can-anyone-help-on-this/#findComment-346909 Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 what's the question? heh Quote Link to comment https://forums.phpfreaks.com/topic/69010-can-anyone-help-on-this/#findComment-346931 Share on other sites More sharing options...
phat_hip_prog Posted September 12, 2007 Share Posted September 12, 2007 So what your saying is they can never have the same start time again? Or next start time can never be within anothers' time period? Quote Link to comment https://forums.phpfreaks.com/topic/69010-can-anyone-help-on-this/#findComment-346935 Share on other sites More sharing options...
watthehell Posted September 12, 2007 Author Share Posted September 12, 2007 I think the question got confusing... I didn't understood myself seeing again .. LOL I made this simple... a) User will select a date (e.g: 2007-9-12). It is stored in a variable $date b) Then he will select a time for reservation from list box, e.g I want to reserve from 9:00 am to 10:00 am on 2007-9-12 But what happened is if the user selects 9:00 am to 10:00am on 12th September it gets saved, and when another user wants to save the same time on 13th September it does not allow (from the code i posted above). I think i could not write the SQL query properly, anyone give a quick glance and give some hints.. plz my query without checking for date SELECT * FROM user_reservation WHERE (user_reserve_time_end > $from AND user_reserve_time_start < $to)"; with date SELECT * FROM user_reservation WHERE (user_reserve_time_end > $from AND user_reserve_time_start < $to) AND user_reserve_date=$date"; Quote Link to comment https://forums.phpfreaks.com/topic/69010-can-anyone-help-on-this/#findComment-347074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.