I have the following simplified while loop code:
while($row = mysql_fetch_array($result)) {
mail($to, $subject, $newMessage, $headers);
}
Is it possible to display a text while the loop goes on, such as “Sending email 1 from 100”, then “Sending email 2 from 100”, etc…? When the while loop finishes, clear the text and show for example, “All mail was sent!”.
I don’t know how to explain it better, what I can easily do is print that text every time we enter the loop, but then the page ends up with 100 texts printed.
I’d like something like a floating div that updates while in the loop, then dissapears.
Hope I have made myself more or less clear!
Thankss!
You’ll have to fill in but so you get the basics, example with jQuery ajax :
Javascript :
PHP send-email.php :
Edit : you’ll need to deal with potential security issues (input parameters, direct calls to the PHP script…), as well as the fact that the whole thing may easily be interrupted by the user.