This topic is locked

conditional emailing

12/6/2007 5:57:08 PM
PHPRunner General questions
G
garivera author

I have 2 tables, emaillist & solicitationlist. emaillist has name, email, variable1, variable2, variable3. solicitation list has title, description, variable1, variable2, variable3.
I want to add records to solicitationlist and have it email to those in emaillist whose variable1, variable2, variable3 are equal to 'yes'. I have this working, but I have duplicate emails to those who have selected 'yes' in variable1, variable2, and variable3.
How can I filter the duplicate emails to ensure each person gets one email no matter how many varaibles the users selects yes to?
Here is some code in before edit. same code is in before add in solicitationlist.
if ($values["variable1"] == "Yes")

{

$rs=db_query("select from emaillist where variable1='Yes'",$conn);

while($data=db_fetch_array($rs))

{ mail($data["Email"], $subject, $message, $headers); }

}
if ($values["variable2"] == "Yes")

{

$rs=db_query("select
from emaillist where variable2='Yes'",$conn);

while($data=db_fetch_array($rs))

{ mail($data["Email"], $subject, $message, $headers); }

}
if ($values["variable3"] == "Yes")

{

$rs=db_query("select * from emaillist where variable3='Yes'",$conn);

while($data=db_fetch_array($rs))

{ mail($data["Email"], $subject, $message, $headers); }

}
thanks.

G
garivera author 12/7/2007

http://www.asprunner.com/forums/index.php?showtopic=5398

HTH Hajo


Unless I am missing something, that wont help me. My code will give me the same result as the provided link.
My problem is some people are in multiple categories, and I dont want to send out multiple emails of the same thing depending on the amount of lists they sign up for. For example, if someone registers and wants to be notified for deals on pens, paper, and pencils. If I have a deal on office supplies, and I want to send to out an email to those who signed up for pens, paper, and pencils, then those people who are signed up for all three will get three emails of the same info. This is what I want to avoid.
Hope this helps?
Gabe