I am trying to send new artist signups that have signed up within the last week to the old artists that match the new artist City or Genre_Select. The query works fine, but i am having problems with duplicates. for instance, if i have New Artist A that is affiliated with Old Artist A through Genre_Select and affiliated with Old Artist B through City, then both Old Artists A and B will receive duplicates in their email messages.
What is happening is that all of the eligable new artists from the query are being emailed to all of the eligable old artists. how can i single these out and send just the new artist information that is intended to just the old artists that have the same City or Genre_Select, instead of sending everything to everyone within the query's guidlines? 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);