I have php form in which you can submit your income / expenditure (basic home budget management). In order to have them auto repeat every month I use code as below
INSERT INTO income (ammount, date, desc, category)
SELECT ammount, now(), desc, category FROM income WHERE recurring=1 and date LIKE '____-__-23'
There's a function called
DAY (synonymous to
DAYOFMONTH), which extracts the day of month from the date field. This means that you can change
date LIKE '____-__-23'
DAYOFMONTH(date) = DAYOFMONTH(NOW())
You will no longer need one script for each day of the month.
Remember not to run those queries just before midnight.
If you want to learn more, read the docs.