when i execute the following code i send an email to members of my database that choose to receive updates. In the email, in the TO: field of the m21.Contact, i get multiple mn1.Artist_Names. and in the actual message, under Artist Name:, i get the names that correspond with the emails in the TO: field. The TO: field in the email ($update_recipient) lists all of the query results for mn2.contact. and because of this, the actual message shows all of the artist names affiliated with the TO: field, even if they are duplicates.
what i want is to send ONE email to EACH of the contacts with the names of new artists that signed up in this week that have the same city and genre of the contact being mail to.
the query does the job right, but i can't seem to format it correctly with the while loop and concatenation. it seems like a simple problem with the logic. can someone please help me? here is the code:
$newartist = mysql_query("SELECT Distinct mn1.City, mn1.Genre_Select, mn1.Artist_Name, mn1.State_or_Province, mn1.Country, mn1.Genre_Enter, mn1.Artist_Function, mn1.Homepage, mn2.Contact FROM Musicians_Network mn1 LEFT JOIN Musicians_Network mn2 ON (mn1.City = mn2.City or mn1.Genre_Select = mn2.Genre_Select) WHERE mn1.Date_Created > DATE_SUB( CURDATE(), INTERVAL 7 DAY ) AND mn2.Updates = 'Yes' ", $db);
while ($myfirstrow = mysql_fetch_array($newartist)) {
$update_email = $update_email.",".$myfirstrow["Contact"];
$update_artist = $update_artist.",".$myfirstrow["Artist_Name"];
}
$update_recipient = $update_email;
$update_subject = "A new artist in your city or genre has been added";
$update_message = "Artist Name: $update_artist";
$update_extra = "From: Boggle_Productions<>\r\nReply-To: ()\r\n";
mail ($update_recipient, $update_subject, $update_message, $update_extra);