Getting values from mysql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    #1

    Getting values from mysql database

    I want to get data that are enter to the database in last 24 hours. How can i do that.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Originally posted by ghjk
    I want to get data that are enter to the database in last 24 hours. How can i do that.
    Do a PHP and MySQL tutorial, start writing some code on how to extract data from the database. When you run into problems with your code, we can help.
    When you already have made code: show that here (with the appropriate code tags) and tell us what the problem is with it.

    Ronald

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      You should use the 'on update current_timesta mp' in mysql.
      Then you can check the dates and times of when something was done.

      Regards.

      (do this after you've considered Ron's post)

      Comment

      • ghjk
        Contributor
        • Jan 2008
        • 250

        #4
        Originally posted by markusn00b
        You should use the 'on update current_timesta mp' in mysql.
        Then you can check the dates and times of when something was done.

        Regards.

        (do this after you've considered Ron's post)

        This is my query . But it is not working.
        [PHP]select Rainfall from rainfall WHERE DATE_SUB(CURDAT E(),INTERVAL 1 DAY)[/PHP]

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          Originally posted by ghjk
          This is my query . But it is not working.
          [PHP]select Rainfall from rainfall WHERE DATE_SUB(CURDAT E(),INTERVAL 1 DAY)[/PHP]
          Use capitals for commands:
          [PHP]SELECT Rainfall FROM rainfall...[/PHP]

          [EDIT]I thought you had a timestamp variable. My Bad:

          You do not have an actual WHERE clause. I don't know about the DATE_SUB(...) function but it should be something like WHERE my_date_variabl e >= DATE_SUB(CURDAT E(),INTERVAL 1 DAY)

          This means you would need to have a variable in the table that recorded the time it was created or editted or whatever (aka timestamp). As I say I have never used that function, but to my knowledge MySQL doesn't store row life? Please correct me if I am wrong!

          Comment

          • ghjk
            Contributor
            • Jan 2008
            • 250

            #6
            Originally posted by TheServant
            Use capitals for commands:
            [PHP]SELECT Rainfall FROM rainfall...[/PHP]

            [EDIT]I thought you had a timestamp variable. My Bad:

            You do not have an actual WHERE clause. I don't know about the DATE_SUB(...) function but it should be something like WHERE my_date_variabl e >= DATE_SUB(CURDAT E(),INTERVAL 1 DAY)

            This means you would need to have a variable in the table that recorded the time it was created or editted or whatever (aka timestamp). As I say I have never used that function, but to my knowledge MySQL doesn't store row life? Please correct me if I am wrong!

            I have done
            [PHP]
            $today = date("y-m-d H:i:s");
            $q = mysql_query("SE LECT * FROM infor WHERE TIMEDIFF('".$to day."',Date) < '24:00:00' ");
            [/PHP]

            Comment

            • TheServant
              Recognized Expert Top Contributor
              • Feb 2008
              • 1168

              #7
              Originally posted by ghjk
              I have done
              [PHP]
              $today = date("y-m-d H:i:s");
              $q = mysql_query("SE LECT * FROM infor WHERE TIMEDIFF('".$to day."',Date) < '24:00:00' ");
              [/PHP]
              So does that code work?

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Yes, THIS THREAD says it is solved.

                Ronald

                Comment

                • TheServant
                  Recognized Expert Top Contributor
                  • Feb 2008
                  • 1168

                  #9
                  lol, good. Thanks for tracking it Ron.

                  Comment

                  • ronverdonk
                    Recognized Expert Specialist
                    • Jul 2006
                    • 4259

                    #10
                    I remember my own answers. See you.

                    Ronald

                    Comment

                    Working...