Hi everyone..
I need to update my table every 5secs.. And am not been able to do it.. Can anyone give me a clue of how I can implement this..
Any help will be greatly appreciated.
Thanks in advance
Rit
php update
Moderator: General Moderators
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: php update
You will have to give us a bit more detail. By "table", do you mean a database table, or an html table on a web page?
Re: php update
it is a database table..
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: php update
Well, you have two main possibilities.
You could write a script for a cron job. Google "cron job" if you don't know what i am talking about. You will probably need root access to your server, and some knowledge of bash scripting.
Or you could create a "pseudo cron job" in php. This is a php script which runs, for example, every time someone requests a webpage from your site. You could use a database to track the last time the script ran, and run the script only if a certain number of seconds have elapsed since the last time it ran. Of course, if no-one accesses your website for, say, 10 minutes, then the script will not run for 10 minutes. But maybe that is not important - if no-one accesses your website in this time, does it matter if the database gets out of date between page requests. The important thing is that the database is updated when a page request is made.
You could write a script for a cron job. Google "cron job" if you don't know what i am talking about. You will probably need root access to your server, and some knowledge of bash scripting.
Or you could create a "pseudo cron job" in php. This is a php script which runs, for example, every time someone requests a webpage from your site. You could use a database to track the last time the script ran, and run the script only if a certain number of seconds have elapsed since the last time it ran. Of course, if no-one accesses your website for, say, 10 minutes, then the script will not run for 10 minutes. But maybe that is not important - if no-one accesses your website in this time, does it matter if the database gets out of date between page requests. The important thing is that the database is updated when a page request is made.