Forum Moderators: coopster
$between_delay = 10; $send_delay = 1; for ( $sent=0; $row = mysql_fetch_array($result); $sent++ ) { if ( ($sent % $between_delay) == 0 ) sleep( $send_delay ); $emailall = $row[0]; $message = stripslashes($message); mail("$emailall", "$subject", "$message", "From: $email"); } That's a nice piece of code, but it doesn't do the trick if I want the user to see what's going on.
What I would like to do is this:
1)execute the script 10 times then pause was 10 seconds
2)notify the user that the script is pausing
3)continue executing after the pause
4)tell the user, how many emails habe been sent before the pause
Is there any way to do this? I've tried out different sleep() tests, but all of the seem to sleep() for the give amout of time and when they're done sleeping, they'll output the whole thing at one time, like this one for example:
while ($x<10) {
$x++;
if($x==5) {
sleep(5);
$msg = "Script executed " . $x . " times. Wait 5 seconds an continue"
print "" . $msg . "<br />";
print "" . date('h:i:s') . "<br />";
}
else if($x==10) {
sleep(5);
$msg = "Script executed " . $x . " times. Wait 5 seconds an continue"
print "" . $msg . "<br />";
print "" . date('h:i:s') . "<br />";
}
}
That script waits for 10 seconds then prints:
<i>
Script executed 5 times. Wait 5 seconds an continue"
17.2.2004 11.23.25
Script executed 10 times. Wait 5 seconds an continue"
17.2.2004 11.23.30</i>
And that's not what I'm looking for. Any ideas?