Jump to content

Can anyone help on this ??


watthehell

Recommended Posts

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

 

Link to comment
Share on other sites

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";

 

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.