...

View Full Version : time redundancy check



ehhwan
02-19-2006, 06:47 AM
i have a problem with time redundancy check.

my system checks whether the date,venue,time start and time end redundant with the records in the database

the codes are :

SELECT * FROM booking WHERE Date = '$Date' AND Venue = '$Venue' AND ((Time_start >= '$TimeStart' AND Time_end < '$TimeEnd') OR (Time_end > '$TimeStart' AND Time_end <= '$TimeEnd'))

if($totalRows_Check!=0)
{
//redundant msg
}
else
{
//proceed
}

data in DB:
Date=2006-02-19
Venue=Hall C
Time_start=09:00:00
Time_end=12:00:00

let say if the user input:
$Date=2006-02-19
$Venue=Hall C
$TimeStart=10:00:00
$TimeEnd=11:00:00


u can see the user input is redundant to the current data in database but the query returns 0 row.i'm so :confused: right now.please someone help me

goughy000
02-19-2006, 02:02 PM
Its probably because of how your times are formatted.

If they were stored in the database as unix time stamps and the times entered by the user were converted to unix time stamps then PHP would be able to compare them.

Although everything i just writ might be wrong...

www.php.net/date

EDIT: adding to that i found another function that would be more useful.. strtotime

10:00:00 -> unix time stamp


$unixtime = strtotime("10:00:00");
echo $unixtime;


Output:


1140343200


Then you would use the date function in your comparing



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum