This topic is locked

Using Email Address from DB

12/19/2005 12:36:51 PM
PHPRunner General questions
D
defcon2000 author

Hello Everyone,
I need help with the following php script.
I have the following statement:
$tmpemailreminder = mysql_query("

SELECT reminder , reminded, emailtoperson1, emailtoperson2, emailtoperson3,

email_address, emailme

FROM reminder, users

WHERE reminder.username = users.username

AND reminder.reminderdate = SUBDATE(CURDATE(), INTERVAL 1 DAY)

AND reminder.status = 'Open'

AND reminder.reminded = 'N

'", $conn) or die('Query failed: ' . mysql_error());
The fields emailtoperson1, emailtoperson2, emailtoperson3 and email_address are populated with email address.
The idea is to run a loop and

if emailme = 'Y' then send email to email_address, with subject "Reminder" and body "reminder"
if emailtoperson1 IS NOT NULL then send email to emailtoperson1, with subject "Reminder" and body "reminder"
if emailtoperson2 IS NOT NULL then send email to emailtoperson2, with subject "Reminder" and body "reminder"
if emailtoperson3 IS NOT NULL then send email to emailtoperson3, with subject "Reminder" and body "reminder"
Can someone help me with this. I noticed that PEAR::Mail is on our server and would like to use this.
Thanks for your help in advance.
Rgds,