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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation PLS Help !!!! Coding

    how to display the page when the Database date is = to the system date?? eg. '$date' = date");





    <php>
    $hour = date("H");
    $min = date("i");
    $date = date("l");
    $Connect = mysql_connect('localhost','root','');
    mysql_select_db('mw');
    $result=mysql_query("SELECT * FROM student WHERE '$hour:$min' > before AND '$hour:$min' < after AND '$date' = date");
    echo"<form name=main method=POST action=verify_attendance.php>";
    </php>

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You need to read our posting guidelines section 2

    http://www.codingforums.com/postguide.htm
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could use the MySQL function CURDATE(), like
    $result=mysql_query("SELECT * FROM student WHERE '$hour:$min' > before AND '$hour:$min' < after AND date = CURDATE()");

    But the rest of the code also looks strang (and probably wount work either). I suppose before, after and date are columnnames of table student (how bizare, but hey ...) where the two first are time-type and tha last is of type date AND that you want the record with date = the current date , and the current time between before and after.
    Rigth ?

    Then you can use
    $result=mysql_query("SELECT * FROM student WHERE before < CURTIME() AND after > CURTIME() AND date = CURDATE()");

    Note : CURTIME() and CURDATE() are MySQL functions, and will use the datetime from the server where the MySQL server runs on. In most cases, this is the same machine (or is a machine with the same systemdate) as where the webserver runs on


  •  

    Posting Permissions

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