Please help me i have confusion in getting categories i want to echo each subcatagory only one time..
<?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 > 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 .= "<li>$subcatagory</li>";
}
} else {
$catagories = "you have no product in your list yet";
}
?>
<html>
<body>
<div class="col-content">
<ul>
<?php echo $catagories; ?>
</ul>
</div>
</body>
</html>
The easiest solution to the problem detailed in the comments is to write the query like:
(though it may not scale well)