The_Return
08-24-2009, 01:29 AM
I have a script where the user submits a message and it goes to the table "jobs" where it puts the message and hostid key. The second script I wanna cron so every 5 minutes it will check if their is a new job and if their is a job to go ahead and complete it then delete it and then check again ..loop and so on.
<?php
ob_implicit_flush(true);
//include("aimclassw.php"); //Toc
//check if their are jobs
$query = "SELECT * FROM jobs WHERE status = '0'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$message = $row['message'];
$hostid = $row['hostid'];
//select all the aims with the host id given
$q = "SELECT aim FROM friends WHERE hostid = '$hostid'";
$re = mysql_query($q) or die(mysql_error());
while($r = mysql_fetch_array($re)){
echo "The message is $message the sender is $hostid";
}//End while loop
$query2 = "DELETE FROM `jobs` WHERE `message` = '$message' AND `hostid` = '$hostid'";
$result2 = mysql_query($query2);
}
?>
<?php
ob_implicit_flush(true);
//include("aimclassw.php"); //Toc
//check if their are jobs
$query = "SELECT * FROM jobs WHERE status = '0'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$message = $row['message'];
$hostid = $row['hostid'];
//select all the aims with the host id given
$q = "SELECT aim FROM friends WHERE hostid = '$hostid'";
$re = mysql_query($q) or die(mysql_error());
while($r = mysql_fetch_array($re)){
echo "The message is $message the sender is $hostid";
}//End while loop
$query2 = "DELETE FROM `jobs` WHERE `message` = '$message' AND `hostid` = '$hostid'";
$result2 = mysql_query($query2);
}
?>