Product Category Dropdown Filter only show categories thats are assigned to the products not all the categories

This commit is contained in:
johnnyq 2025-08-15 19:26:42 -04:00
parent 37bef2d824
commit 2333fa2d9b
1 changed files with 1 additions and 1 deletions

View File

@ -91,7 +91,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<option value="">- All Categories -</option>
<?php
$sql_categories_filter = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC");
$sql_categories_filter = mysqli_query($mysqli, "SELECT DISTINCT category_id, category_name FROM categories INNER JOIN products ON product_category_id = category_id WHERE 1 = 1 AND product_$archive_query $type_query ORDER BY category_name ASC");
while ($row = mysqli_fetch_array($sql_categories_filter)) {
$category_id = intval($row['category_id']);
$category_name = nullable_htmlentities($row['category_name']);