RE: [PHP] excluding same field values in mysql

From: Date: Thu, 20 Feb 2003 01:47:09 +0000
Subject: RE: [PHP] excluding same field values in mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136295@lists.php.net to get a copy of this message
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:rusty_81@msn.com] Sent: February 19, 2003 6:23 PM To: php-general@lists.php.net 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: company1@whatever.com company2 email: company1@whatever.com 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

« previous php.general (#136295) next »