RE: [PHP] Re: excluding same field values in mysql
| From: | Luke Woollard | Date: | Thu, 20 Feb 2003 13:42:24 +0000 |
| Subject: | RE: [PHP] Re: excluding same field values in mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136292@lists.php.net to get a copy of this message | ||
MORE INFORMATION:
http://www.w3schools.com/sql/sql_distinct.asp
-----Original Message-----
From: larry [mailto:larry@shug.atlsfl.adelphia.net]On Behalf Of
no-spam----me@larrykagan.com
Sent: Thursday, 20 February 2003 12:31 PM
To: php-general@lists.php.net
Subject: [PHP] Re: excluding same field values in mysql
In your query throw a 'DISTINCT' in right after your 'SELECT';
Sunfire <rusty_81@msn.com> wrote:
> 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