Re: Unique Results?
| From: | Janet Valade | Date: | Wed, 16 Jan 2002 21:48:21 +0000 |
| Subject: | Re: Unique Results? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15897@lists.php.net to get a copy of this message | ||
$result = mysql_query("select distinct country from search");
Janet
----- Original Message -----
From: "Chris Payne" <chris@planetoxygene.com>
To: <php-db@lists.php.net>
Sent: Wednesday, January 16, 2002 1:29 PM
Subject: [PHP-DB] Unique Results?
Hi there everyone,
(Sorry if you got this twice, I don't think my mail server posted it
earlier).
I use the following code to populate a dropdown box from a MySQL database:
$db = mysql_connect("localhost","^^^","^^^");
mysql_select_db("mydb",$db);
$result = mysql_query("select country from search");
if ($result)
{
echo "<SELECT NAME='country'>";
while ($myrow = mysql_fetch_array($result))
{
echo "<OPTION VALUE=\"".$myrow["country"]."\">".
$myrow["country"]." </OPTION> ";
}
echo "</SELECT>";
}
However, this database has multiple country names the same (Aswell as unique
ones) how can I display just ONE of each entry? IE: say there are 5 africa,
3 britain etc ..... I only want the list to show 1 of each and not 5 and 3
and so on - how is this possible? Please help :-)
And thank you to everyone who helped me with an earlier enquiry, it's very
appreciated :-)
Chris Payne
www.planetoxygene.com