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
https://forums.phpfreaks.com/topic/69149-solved-help-on-this-query/
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..

 

 

Archived

This topic is now archived and is closed to further replies.

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