faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 13 people (8%) answered Yes
Recently 0 of 10 people (0%) answered Yes

Entry

How do I set a value into a MySQL database that will be displayed by PHP and have it decrement daily

Aug 20th, 2006 10:16
lorenzo campanis, Kathleen Locher,


You will need to store a date for comparison in the DB, and the easiest
way to do it, would be to store the date in unix timestamp using the
time() function. However, you ll need to add the difference you want,
such as a day in your case. This will give you:
$tomorrow = time() + (24 * 60 * 60);//add a day to timestamp
Then having a function call when the page loads you can compare it with
the current time.
if($myTime == time())
{
...take action
}
$myTime is the result of a query in the database for the stored timestamp.