Hello, HashCode.

I have a table in which there is a number 0 (for example), and I need it to automatically increase every 14 hours by 1 and so on all records. How to do it or in what direction to dig?

  • Let me ask, why do you need it? Maybe the solution to the problem lies in another area? - Ale_x

4 answers 4

Create a JOB in which you write the usual update with the changes you need, and in the JOB settings, specify the call frequency and that's it.

Every 14 hours, using cron for example, make a query to the database

UPDATE `table_name` SET `counter_name` = `counter_name`+1 

    Php script can still be called with cron . He will automatically call every 14 hours. And the php script will then update "th increase by one value.

      It is not clear what tools you use. Maybe you are doing a desktop application (in C #, for example), maybe a Web application. I will focus on the latter, since it seems to me that this is what you need.

      You can easily make such a thing: for this you need to leave a timestamp somewhere (in a text file) every 14 hours, where the last increment was made. Then each time you enter the site, the script (rather, PHP) will have to look at that very label and subtract it from the current one. Then you will only have to convert the difference in time stamps into hours and check whether it is equal or not more than 14, if so, then update the label in the same file and increment a specific value in the database.

      • Yes, you are right php and mysql, but here's the problem, but if no one is on the site. - Angus123
      • Well, it will be easy to fix (knowing math =)). We take the difference in time stamps and determine the quotient with the divider 14. We take the whole part of the quotient and increment it as many times as the quotient. Then we take the rest of the time and write to the file the current time + the rest, converted into a timestamp. - Salivan
      • if it is php, then there is such a topic as cron, in this direction and dig. when it is installed, it indicates the frequency of the call, inside make your own query for DB - zippp
      • @zippp, damn it, you oak tree? Here the fact is that someone will still have to go to the site for this increment! - Salivan
      • I think you are an oak tree. - Veikedo