php - how to auto decrement a column in the database daily -


i have column name remainingdays. counts remaining days since last donation of user. how can auto decrement column daily. example column has value of 90 tommorow becomes 99. automatically updates database without users interaction.

i add date field database. each time donation made, update date , reset counter.

then whenever need check or current value of counter, change select using to_days function in mysql converts date number-of-days value.

select current_count - to_days(now())-to_days(date(last_donation)) result

so if last update made yesterday, counter value reset beginning , yesterdays date have been recorded. if value set 100, today when select return 99 , in ten days return 90.

this how i'd anyway , assumes mysql i'm sure type of functionality available in sql database sever environments.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -