Jump to content


Photo

loop equation needed


  • Please log in to reply
3 replies to this topic

#1 tgavin

tgavin
  • Members
  • PipPipPip
  • Advanced Member
  • 176 posts
  • LocationNaples, FL

Posted 09 May 2006 - 01:47 AM

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.
A noble spirit embiggens the smallest man.
- Jebediah Springfield

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 May 2006 - 02:09 AM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 09 May 2006 - 02:57 AM

Or you could try [man]ob_flush[/man]().

#4 tgavin

tgavin
  • Members
  • PipPipPip
  • Advanced Member
  • 176 posts
  • LocationNaples, FL

Posted 09 May 2006 - 03:04 AM

[!--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) View Post[/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
$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;
        }
    }
}
Thanks for your help!

A noble spirit embiggens the smallest man.
- Jebediah Springfield




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users