Hello,
I am trying to email my customers with appointment reminders -
however, my script will send the email to the last email in the query.
What is happening with this script is the last email in the loop is receiving everyones appointments in addition to their appointment.
I need each person that has an upcoming appointment receive an email with just their information from the database in the message of the email.
<code>
$query_notifier = "SELECT users.email_address, users.username, artists.nick_name, artist.follow_up_date, DATE_FORMAT(follow_up_date, '%b %d, %Y') AS hmfollow_up_date
FROM users INNER JOIN artists
ON users.username = artists.username
WHERE internal_parasite.follow_up_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 7 DAY)";
$rsnotifier = mysql_query($query_notifier, $db);
if (!$rsnotifier) {
echo "Could not sucessfully run query ($query_notifier) from DB: ". mysql_error();
exit;
}
if (mysql_num_rows($rsnotifier) == 0) {
echo "no rows found, nothing to print so am exiting";
exit;
}
while ($row_rsnotifier = mysql_fetch_assoc($rsnotifier))
{
$email_address = $row_rsnotifier['email_address'];
$subject = 'Appointment Reminder';
$message = "<html>
<head>
<title>Calendar Appointment</title>
</head>
<body style='background-image:url(http://www.images/bkrnd.jpg); background-repeat:no-repeat; background-position:center;'>
<p></p>
<p></p>
<p></p>
<p></p>
Hello, $row_rsnotifier[username] <br />
<h3>This is a friendly reminder from XYZ:</h3><br/>";
do{
if ($row_rsnotifier[nick_name] != '')
$message .= "$row_rsnotifier[nick_name] is due on $row_rsnotifier[hmfollow_up_date] <hr color='#FFCE00' size='1'><br />";
}
while ($row_rsnotifier = mysql_fetch_assoc($rsnotifier));
$message .='<p></p>
</body>
</html>';
}
mysql_free_result($rsnotifier);
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'From:
[email protected]';
mail($email_address++, $subject, $message, $headers);
</code>
Thank you to all in advance!