I want to get data that are enter to the database in last 24 hours. How can i do that.
Getting values from mysql database
Collapse
X
-
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.Originally posted by ghjkI want to get data that are enter to the database in last 24 hours. How can i do that.
When you already have made code: show that here (with the appropriate code tags) and tell us what the problem is with it.
Ronald -
Originally posted by markusn00bYou 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
-
Use capitals for commands:Originally posted by ghjkThis is my query . But it is not working.
[PHP]select Rainfall from rainfall WHERE DATE_SUB(CURDAT E(),INTERVAL 1 DAY)[/PHP]
[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
-
Originally posted by TheServantUse 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
-
So does that code work?Originally posted by ghjkI 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
-
-
-
Comment