Re: excluding same field values in mysql

From: Date: Thu, 20 Feb 2003 01:30:30 +0000
Subject: Re: excluding same field values in mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136291@lists.php.net to get a copy of this message
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

« previous php.general (#136291) next »