Satrt/Stop button for loop
Posted: Thu Oct 09, 2014 5:32 am
Hi,
How can one stop a loop once started with a button?
I can start the while loop but can't stop it, the button request is coming from an ajax post
Here's the code:
How can one stop a loop once started with a button?
I can start the while loop but can't stop it, the button request is coming from an ajax post
Here's the code:
Code: Select all
$run=false;
if (isset($_GET['btnRequest']) && !empty($_GET['btnRequest'])){
$btnRequest = $_GET['btnRequest'];
if($btnRequest=="startLoop"){
$run=true;
echo "started..";
}else if ($btnRequest=="stopLoop"){
$run=false;
echo "stopped..";
}
$count = 0;
while ($run==true){
echo "looping..<br/><br/>";
sleep(1);
$count++;
}
}