Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    time redundancy check

    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 right now.please someone help me

  • #2
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    PHP Code:
    $unixtime strtotime("10:00:00");
    echo 
    $unixtime
    Output:
    Code:
    1140343200
    Then you would use the date function in your comparing
    Last edited by goughy000; 02-19-2006 at 01:17 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •