What i want is after user click specific button on my webpage, I will check with if(isset()) than run the follow commend for loop.
This is what i have done so far. If $balance is 10 than for loop should run 10 times. For loop run instantly 10 times without refreshing the page but sleep() function help delay it. I need to refresh the page every 1 loop complete than continue the rest 9 loops. Every loop need to refresh page every time its run.
$balance = '10';
$wallet = $_SESSION['wallet'];
if(isset($_POST['click'])){
if($balance != 0){
for($x = 0; $x < $balance; $x++){
$sql = $conn->query("UPDATE wallets SET balance = balance - 1 WHERE wallet = '$wallet' " );
//some code to complete this
....
//this is where the page to refresh
header("location: click.php?e=2");
}
sleep(5);
}
else{
header("location: click.php?e=1");
}
}
What i expected is .... 1 loop complete refresh page 1 time than continue another 1 loop than refresh page 1 more time than continue....