tgavin Posted May 9, 2006 Share Posted May 9, 2006 I can't get my head around how to write this.I'm sending email batches, let's say 100 at a time out of 500 total. I already have the process in place to do this, but I don't know how to write out what I want to print to the screen.Basically, on the first loop I want to say "Batch number 1 completed. 100 emails sent. 400 remaining"On the second loop, "Batch number 2 completed. 200 emails sent. 300 remaining"And so on.Thanks for any help. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 9, 2006 Share Posted May 9, 2006 umm.. ghetto solution™ !$count = 1;for (...) { //for loop that sends email out //'send email out' script hereecho "Batch number ".$count." completed. ".($count*100) emails sent. ".(500-($count*100))." remaining."$count++;}i was just kidding. that won't REALLY work. if you want it to update live then you will have to use javascript or ajax. Quote Link to comment Share on other sites More sharing options...
trq Posted May 9, 2006 Share Posted May 9, 2006 Or you could try [man]ob_flush[/man](). Quote Link to comment Share on other sites More sharing options...
tgavin Posted May 9, 2006 Author Share Posted May 9, 2006 [!--quoteo(post=372475:date=May 9 2006, 02:09 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 9 2006, 02:09 AM) [snapback]372475[/snapback][/div][div class=\'quotemain\'][!--quotec--]i was just kidding. that won't REALLY work. if you want it to update live then you will have to use javascript or ajax.[/quote]Actually, that was close :)The script I have refreshes after each batch is sent, so doing it in PHP is fine. Maybe this will help[code]$count = 0;$precount = 500;$queue_size = 100;$queue_refresh = 25;$query = mysql_query("SELECT * FROM send_queue LIMIT $queue_size") or die(mysql_error());if($row_prefs['ignore_abort'] == '1') { echo "sending message goes here";} else { echo "sending message goes here";}while($row = mysql_fetch_assoc($query)) { $count = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM send_queue"),0); $to = $row['queue_email']; if($sendType == '2') { email_html(); if($sent) { // mail sent, remove addresses from queue $delete_query = mysql_query("DELETE FROM send_queue WHERE queue_id = '$row[queue_id]' AND queue_email = '$row[queue_email]'") or die(mysql_error()); echo "<meta http-equiv=\"refresh\" content=\"$queue_refresh;url=send_batch.php\">"; } else { echo $error_msg; exit; } }}[/code]Thanks for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.