Page 1 of 1

Resetting record on month end/start

Posted: Wed Apr 09, 2008 3:39 pm
by leon_nerd
I am working on a PHP application. It involves a database table which maintains some candidates and user votes for each of them. Now what I want is at the end of each month or starting of the month, I want the "votes" field in the table to be reseted to zero (0). Now, I am not able to decide how to achieve this. Should I write a php script on the homepage to check if the current day is 1st day of the month. If yes, then I can reset the votes else leave it. The downside of this logic is what if the site is not opened on the 1st day of the month at all, though it is a near impossible case. Can there be a better approach to solve this issue?

Thanks.

Re: Resetting record on month end/start

Posted: Wed Apr 09, 2008 5:06 pm
by Christopher
You should probably not have a "'votes' field in the table". You should probably have a separate table where each record contains the voterID, vote and timestamp. Then to tally votes you select records between the first and last day of the month in question.