Jump to content

[SOLVED] Help on this --- Query


watthehell

Recommended Posts

hi,

 

CAn anyone guide me on this:

 

I need to check for a user reservation (time and date) and wrote this but it does not seem to work. Any help will be most welcome.

<?php

// here from--to is user selected time e.g 9 am to 10am

if(($from <$to))

{

/* checking whether the user selected time overlaps the reserved time this works fine, the problem i am having is while checking for date it does not work..I wrote those 2 queries in one */

$que1= "SELECT * FROM user_reservation WHERE (user_reserve_time_end > $from AND user_reserve_time_start < $to)";

 

$que_date="SELECT * FROM user_reservation WHERE user_reserve_date LIKE ".$date;

$result_date = mysql_query($que_date);

$result1 = mysql_query($que1);

 

if (mysql_num_rows($result1)!=0 && mysql_num_rows($result_date)!=0)

 

{

$var1=true;

$app->error_display_type=2;

$app->error("This record overlaps existing time slots");

    }

else

{

                // inserting value this is working

                  }

 

?>

The main problem is that this condition checks if the time overlaps or not but it does not check for date, it does not allow the user to save same time on different date.

 

thnks...

Link to comment
Share on other sites

Thanks a lot... it worked..... IT took me whole day but still i couldn't figure out what the problem was...

 

After all Genius is Genius ;)

 

One more question :

 

Why doesn't mysql compare the date like

 

Select * from reservation where mydate=2007-9-14;

 

And in table i have 4 records that matches this record..

 

Anyway thanks a lot..

 

 

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.