in reply to Re: Updating variable in a loop
in thread Updating variable in a loop

So I would use another loop within my loop? Here's what I'm doing:
$SQL = "Select * from database where (TO_DAYS(enddate) - TO_DAYS(Now() +) = 8) AND payment!='premium'"; &Do_SQL; $recordcount = $sth->rows; if ($recordcount > 0) { $sendEmails = 'yes'; } if ($sendEmails eq 'yes') { $count = 0; while ($pointer = $sth->fetchrow_hashref) { $contact = $pointer->{'contact'}; $toemail = $pointer->{'email'}; open (MAILPROG....."; SEND THE EMAIL HERE.... close (MAIL); print "email sent to: $contact <$toemail>\n"; $count++ } print "Sent $count emails.\n"; $action = "Email Reminders sent!"; $log = "Sent $count emails."; &log_it;
I'd like $log to also have every email address that received an email. It would look something like this in the log:
Sent 4 emails.<br> Email sent to user1<br> Email sent to user2<br> Email sent to user3<br> Email sent to user4<br>
I need to get the $log variable within my existing loop but have it updated with every email. So do I have to run a separate loop within my loop?