timed functions and cycles
Posted: Mon Dec 29, 2003 10:47 am
I want to create a function that would do queries from a database during a given time period.
As an example, during 45 sec the function should make a query from the database in every 5 sec and check the field 'control' if it has changed from '0' to '1' or not.
If the value is '1', the cycle should end in there and launch 'function first()' and also start a new cycle for 45 sec that queries in every 5 sec for the value '1' in the database field 'control2'. Again, if the value is '1' it should end the current cycle, launch 'function second()' and end the script.
If during the first cycle no changes in the database were detected 'function three()' should be launched and a new cycle should be started too.
If during the second cycle no changes in the database were detected 'function three()' should be launched and the script should end its work.
Script would be launched with 'exec()'
?>
As an example, during 45 sec the function should make a query from the database in every 5 sec and check the field 'control' if it has changed from '0' to '1' or not.
If the value is '1', the cycle should end in there and launch 'function first()' and also start a new cycle for 45 sec that queries in every 5 sec for the value '1' in the database field 'control2'. Again, if the value is '1' it should end the current cycle, launch 'function second()' and end the script.
If during the first cycle no changes in the database were detected 'function three()' should be launched and a new cycle should be started too.
If during the second cycle no changes in the database were detected 'function three()' should be launched and the script should end its work.
Script would be launched with 'exec()'
Code: Select all
<?php
$times = 9;
$count = 0;
while ($count < $times) {
$count++;
$query=mysql_query("SELECT devices FROM control");
flush();
sleep(5);
}
?>?>