I need a php script that connects to the DB every 5 minutes and checks if a new raw was added. In My specific case I want this script to check every 5 min if there is a new order added in the db.
thanks for the helpers :wink_1:.
Printable View
I need a php script that connects to the DB every 5 minutes and checks if a new raw was added. In My specific case I want this script to check every 5 min if there is a new order added in the db.
thanks for the helpers :wink_1:.
Run this as a commandline PHP script, if you run it as a webpage you'll get a timeout after 60 seconds.PHP Code:while(1) {
$query = mysql_query("SELECT COUNT(*) as count FROM your_table_here");
$result = mysql_fetch_assoc($query);
if($result['count'] != $count) {
$count = $result['count'];
echo "New number of rows is: $count";
}
sleep(300);
}
another way use cron job !
PHP file
PHP Code:$query = mysql_query("SELECT COUNT(*) as count FROM your_table_here");
$result = mysql_fetch_assoc($query);
if($result['count'] != $count) {
$count = $result['count'];
echo "New number of rows is: $count";
add cron job in cpanel with minutes (*/5)
cpanel web hosting instructions - cron jobs
No nickwall, I suggested this but deleted it straight away as that won't work in this case, unless he stores the row count as a variable in a text file or database or something, FragFrog's way is probably simpler.
Quite so. Also, running it in a dosbox makes it very easy to check wether or not extra rows have been added, especially if you add a timestamp to the echo. You'd just run the program (make a shortcut to execute PHP with the filename as variable) and when a row is added the program will say so.
Don't really see the need for such a program though, but thats not my concern :)
//edit
By the way, I did something similar for the Volamir monsterengine (Volamir is a browser-based MMORPG I'm writing), maybe this screenie will elaborate things a bit better:
http://members.home.nl/matthijsdorst...sterengine.JPG
thanks alot fragfrog :laugh_1: