Walid Lamhibi
Walid Lamhibi

Reputation: 21

Auto change variable by Time in PHP and mysql

actually i'm making a web-application in PHP using mysql. this web-application is for manage people works in a company, there's a table in the database called 'employe' where there's all the informations about someone working in the company, and i have to auto change (increment) 'echelon' attribute every 2 years (exemple from 1 to 2). I don't know the idea, how to do this .. please I REALLY NEED HELP from you guys.. And Thanks.. !!

Upvotes: 2

Views: 138

Answers (1)

shabeer
shabeer

Reputation: 1064

In mysql you can add event. In phpmyadmin you can see the option to add event. In that you can add the increment code.

update `table_name` set `echelon`=`echelon`+1;

For more information about event please refer. http://dev.mysql.com/doc/refman/5.1/en/create-event.html

This is the code that you can add event for every 2 year.

CREATE EVENT `your_even_name` ON SCHEDULE EVERY2YEAR ON COMPLETION NOT PRESERVE ENABLE DO UPDATE  `table_name` SET  `echelon` =  `echelon` +1;

Upvotes: 2

Related Questions