Forum Moderators: coopster

Message Too Old, No Replies

Returning field results but no duplicate entries

         

jackblack1

1:05 am on Oct 30, 2005 (gmt 0)



I have a large MySql database full of addresses of clients.

I am trying to use php to retrieve and display a list of all the countries that my clients exist in. Which I can do:

--------
$sql = "SELECT * from Sheet1" ;
$qry=mysql_query($sql);
while ($result= mysql_fetch_array($qry))
{
echo "".$result[11]."<br>";
}
--------

However you can see the problem is this returns EVERY clients country so I end up with a list of duplicate countries.

I would like to display the list of countries but not repeat any countries in the list.

I am a newbie, so please be easy on me :)

B

ergophobe

1:42 am on Oct 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld JB

The easiest thing is just to use this select:

SELECT DISTINCT countries FROM Sheet1 ORDER BY countries

That will give you an alphabetical list.