I've got a variable that will increment upon a user's action. Example: They click a link, and it adds 1 to the variable. The variable is then shown to the screen. I want this variable to be reset to 0 for the user, anytime the server's time has hit Midnight. Could you provide a simple example script that does something like this so I can examine it and learn how it works please?
2 simple solutions: 1, Cron job 2, If you have enough traffic and/or you don't care if it resets some minutes later, you can check the time in a config file that is loaded every time a user visits a page on your site. You should also have another record in your (let's say options) table storing your last time of reset - either a timestamp or just the name/number of the day. Do you need a script to reset the variable for the user? "UPDATE `table` SET `var` = 0 WHERE `user` = 'youruser'
1. add a field contain date 2. "UPDATE table SET click = 0 WHERE last_click < '" . date("Y-m-d") . "'" 3. update clicks "UPDATE table SET click = click + 1, last_click = '" . date("Y-m-d") . "' WHERE user = 'youruser'"