I must to create a menù that contain a list of subcategory items group by mother category and take these values from product table:
Category
Category
I got this:
<?php
$query_cat = $db->prepare("SELECT * FROM products GROUP BY category ORDER BY category");
$query_cat->execute();
print '<li><strong>'. $category . '</strong></li>'; //Category
while ($cat_row = $query_cat->fetch()) { //Subcategory
print '<li><a href="/category/'. $cat_row['4'] .'">'. $cat_row['4'] .'</a></li>';
}
?>
The products
table structure is
ID, name, stars, brand, category, priceavg, first-category
How i can get the category name and put in top of the element?
Thanks to all for the help provided.