I have a database of several hundred titles and each record has a category.. There are only about 8 categories total. I'm trying to loop through and print a list of the 8 categories. If someone adds a new title with a new category the list would then have 9 categories. As you can see with the code below, I can loop through and print the category but I end up with a list of hundreds of categories, most being dupes. How do I skip a category if it's already been printed? Sorry, I know this is simple but I'm lost.
while ($pointer = $sth->fetchrow_hashref) { $category = $pointer->{'category'}; print "<LI>$category\n"; } #end while
In reply to Printing Categories from SQL search by htmanning
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |