Hi, i have a website and i would like to offer a pay per use service based on a 30 day fee, the thing is i have a field called "date" on my sql table and another called "lastlogin", lastlogin shows the current date, how can i perform a simple day count operation and know if 30 days have gone by? i store the data as a date format on mysql with this settings:
$date=date("Y-m-d G:i:s");
Thanks a lot.
Whatabout DATE_ADD() or DATE_SUB() functions if you work with MySQL.
Zdenek
$result = "SELECT * FROM USERS_TABLE WHERE dateofregistry < ".date("Y-m-").(date("d") - 30).date(" G:i:s") or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $result = mysql_query("UPDATE USERS_TABLE SET allowed = '0'"); die; }
USERS_TABLE
allowed
What am trying to do here is to count from the DATEOFREGISTRY 30 days, if they have passed set the field 'allowed' to '0' on the same table to denied access but something is wrong :S
I ment something like this:
You can easilly do this using just one SQL query:
$result = mysql_query("UPDATE `USERS_TABLE` SET `allowed` = '0' WHERE date_add(dateofregistry, INTERVAL 30 day) < now()");
in your code are many errors.