} else { $sort_type = 'default'; } } $productMgr = new ProductManager(); $sorted_products = []; if ($filter_type == 'all' && $sort_type != 'default') { $sorted_products = $productMgr->sortAll($sort_type); } else { if ($filter_type != 'all' && $sort_type == 'default') { $sorted_products = $productMgr->filterProduct($filter_type); } else { if ($filter_type == 'all' && $sort_type == 'default') { $sorted_products = $productMgr->getAllProduct(); } else { $sorted_products = $productMgr->sortWithFilter($filter_type, $sort_type); } } } if (!empty($sorted_products)) { /* ?> <h2 class="title text-center"><?=$display ?></h2> <?php */ //put the result into session $_SESSION['results'] = $sorted_products; foreach ($sorted_products as $eachProduct) { $product_name = $eachProduct["product_name"]; $price = $eachProduct["price"]; $product_id = $eachProduct["product_id"];