i have confusion in getting subcategories i want to echo each subcatagory only one time..
<p>Please help me i have confusion in getting categories i want to echo each subcatagory only one time..     </p>

<pre><code>&lt;?php
mysql_connect("localhost", "root", "")or die(mysql_error())//connect to mysql;
mysql_select_db("ubcommerce")//select database;
$catagories = "";
$sql = mysql_query("SELECT * FROM inventory ORDER BY subcatagory DESC")//select data from table;
$found = mysql_num_rows($sql);
if ($found &gt; 0) {
    while ($row = mysql_fetch_array($sql)) {
        // Gather all $row values into local variables for easier usage in output 
        $subcatagory = $row['subcatagory'];
        $link = $row['catagory'];
        $link = lcfirst($link);
        $catagories .= "&lt;li&gt;$subcatagory&lt;/li&gt;";
    }
} else {
    $catagories = "you have no product in your list yet";
}
?&gt;

&lt;html&gt;
    &lt;body&gt;

    &lt;div class="col-content"&gt;
        &lt;ul&gt;
&lt;?php echo $catagories; ?&gt;
        &lt;/ul&gt;
    &lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
