Jump to content

[SOLVED] Selecting a distinct db column fields


jaxdevil

Recommended Posts

ok, I am trying to select distinct column data. I.e. I have in my database many columns and one of the columns is 'man' (for manufacturers) I am trying to pull a query that will return all the unique manufacturer entries. Say I have 'Nike' and 'Reebok' and 'Whatever'. And I have Nike 60 times, Rebook 12 times, and Whatever 2 times. I want it to return just 1 Nike, 1 Reebok and 1 Whatever. Below is the code I am using, obviously it is not working. Who knows what to do here? I appreciate it...

 

<?php
require($_SERVER['DOCUMENT_ROOT'] . "/config.inc.api.php");
?>
<?php


$sql = "SELECT DISTINCT `man` FROM products LIMIT 5";
$query = mysql_query($sql);

				while ($row = mysql_fetch_array($query)) {

         			echo '<li onClick="fill(\''.$row['man'].'\');">'.$row['man'].'</li>';
         		}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.