Hi all,
Having a problem here. I have a table that lists records, and one of the columns is called "Category". I have on my index page a listing of categories the user can click on to view all listing in that category. To save me having to type out links for every category, I have the following loop in place, which checks column "category" for the names of the categories, and prints them out with a link to that category page.
This works fine, and loops the <li> tags and adds the links nicely. However, what I did not bank on, is that it calls ALL cells within the db that have a category name in, so if there are duplicates (i.e I put three entries into the db under category "Linux") then I get:
Linux
Linux
Linux
...amongst my other categories 🙁
Any ideas of how I can get the script to list the unique category names once and loop with links? This is my current code:
$i=0;
while ($i < $num) {
$category=mysql_result($result,$i,"category");
echo "<li>";
echo "<a href=\"$category.php\">$category</a>";
++$i;
}