I have a user table, where users need to be approved, i want to show users who are not approved and is registered more than 7 days ago.
My user_regdate is a timestamp created with php time() function.
This is what i try, it does not works:
mysql_query("select * from users WHERE user_regdate < now() - interval 7 day AND approved='0' order by id;");
Thanks
PHP's timstamps are a simple integer, whereas MySQL's now()
returns a datetime value. Most likely this will fix up the query:
SELECT ... WHERE user_regdate < unix_timestamp(now() - interval 7 day)) ...
Basically, without the unix_timstamp() call, you're comparing apples and oranges.
Primitive solution at best, but im not the best at MySQL time calculation
$timestamp = strtotime("-7 days");
mysql_query("SELECT * FROM users WHERE user_regdate < $timestamp AND approved = 0 ORDER BY id");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With