Page 1 of 1

do... while loop to send email once only

Posted: Mon Mar 23, 2009 6:15 pm
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));
?>
 

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

Posted: Wed Mar 25, 2009 1:56 am
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.