If you only want one email do a select distinct email that way only one email address will be brought back from you query.
>$query=mysql_query("select company, Email from members"); $query = mysql_query("select company, distinct(Email) from members"); if you want a good book for this check out MySQL by Paul DuBois. -----Original Message----- From: Sunfire [mailto:[EMAIL PROTECTED]] Sent: February 19, 2003 6:23 PM To: [EMAIL PROTECTED] Subject: [PHP] excluding same field values in mysql hi im making a mailing system for a company. i have to find all email addresses in a table and send email to all of them. the problem comes in when more than 1 company has the same email address (owned by same person). what i have to do is if more than 1 company has the same email address only use one of them that are the same for the email not all of them.. example: company1 email: [EMAIL PROTECTED] company2 email: [EMAIL PROTECTED] in the example above i want to only use one of those addresses since they would end up getting 2 emails and that wouldnt look right.. code i have so far is: <?php //connect to db stuff here $query=mysql_query("select company, Email from members"); while($mail=mysql_fetch_array($query)){ mail($mail[Email], $subject, $message, "from: $sender"); echo "mail was sent to: $mail[company]<br>"; } echo "<a href=\"main.php\">go back to main menu</a>"; ?> works fine except only using an email address 1 time if more than one of the same email.. anybody have any ideas how to fix this? tnx --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php