Jump to content

loop equation needed


tgavin

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/9354-loop-equation-needed/
Share on other sites

umm.. ghetto solution™ !

$count = 1;
for (...) { //for loop that sends email out
//'send email out' script here

echo "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.
Link to comment
https://forums.phpfreaks.com/topic/9354-loop-equation-needed/#findComment-34484
Share on other sites

[!--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!
Link to comment
https://forums.phpfreaks.com/topic/9354-loop-equation-needed/#findComment-34505
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.