do... while loop to send email once only

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

do... while loop to send email once only

Post by ninethousandfeet »

hello,
i've made some progress, but still having slight issues...i am trying to send just ONE email to users that are involved in a conversation when a new comment is posted in that conversation... the way i have my code right now, the correct users are getting emails; however, they are receiving multiple emails each time one new comment is posted... how can i limit it so that each user receives just one email when a new comment is posted in their conversation?
thank you!

Code: Select all

 
<?php do {
$email = $row_getALLemails['email'];
$subject = 'You have a new comment!';
$message = 'You have a comment in the following conversation: $commentTitle.  
Login at http://www.shareYOURdiscount.com!
Thank you!';
mail($email, $subject, $message, "From: shareYOURdiscount.com <jhgroup@shareyourdiscount.com>");
} while ($row_getALLemails = mysql_fetch_assoc($getALLemails));
?>
 
sujithtomy
Forum Commoner
Posts: 46
Joined: Tue Mar 24, 2009 4:43 am

Re: do... while loop to send email once only

Post by sujithtomy »

Hello,

Before do -- while loop, get all email-ids on a post to an array (php) and use array_unique() function — to Removes duplicate values from an array.

then use result from array_unique() to sent emails, ie in Do-While loop.
Post Reply