20, 'ipad' => 21, 'macbook' => 22, 'airpods' => 23, 'accessories' => 24, ]; if (isset($categoriesConfig[$currentCategory])) { $catId = $categoriesConfig[$currentCategory]; } // Fetch available attributes for the category if selected $attributes = []; if ($catId) { // Show attributes related to the active category $stmtAttr = $conn->prepare(" SELECT a.attributeID, a.name, a.unit, a.dataType FROM attributes a JOIN categoryAttributes ca ON a.attributeID = ca.attributeID WHERE ca.categoryID = ? ORDER BY a.name "); $stmtAttr->bind_param("i", $catId); $stmtAttr->execute(); $resAttr = $stmtAttr->get_result(); while ($row = $resAttr->fetch_assoc()) { $attributes[] = $row; } $stmtAttr->close(); } else { // If no category selected, just fall back $resAttr = $conn->query(" SELECT a.attributeID, a.name, a.unit, a.dataType FROM attributes a ORDER BY a.name LIMIT 5 "); if ($resAttr) { while ($row = $resAttr->fetch_assoc()) { $attributes[] = $row; } } } ?>