-3

Is there a way of making my php code run every couple of seconds I need it to echo the contents of a column onto my html page but I cant work out for the life of me to get it to do it every couple of seconds or to do it when ever the database gets updated for example if the database gets a new value then run my code.

Thank You, Lees

Lees00
  • 1
  • 1
  • 4
    Depends on your use case, but research the terms "AJAX polling" and "websockets". A bit about it can be read in [this question](https://stackoverflow.com/questions/4642598/short-polling-vs-long-polling-for-real-time-web-applications). – El_Vanja May 11 '21 at 09:49
  • There are no promising attempts known to implement such feature in pure server side scripting. – arkascha May 11 '21 at 10:01

2 Answers2

0

If you wan to run PHP code after specific time there's two ways:
1- You can create CRON JOB
2- You can use task scheduler to run code see this post (Recommended)

Do a PHP task every 1 minute

Faizan Ali
  • 297
  • 2
  • 9
-1

watch -n 2 /usr/bin/php PATH_TO_SCRIPT

Tester
  • 1
  • 1