Page 1 of 1

php update

Posted: Sat Jul 31, 2010 12:39 am
by rit
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

Re: php update

Posted: Sat Jul 31, 2010 1:39 am
by cpetercarter
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

Posted: Sat Jul 31, 2010 3:22 am
by rit
it is a database table..

Re: php update

Posted: Wed Aug 04, 2010 5:09 pm
by cpetercarter
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.