if(isset($_SESSION['sub_cat_id']) && $_SESSION['sub_cat_id'] != ''){
$sql = 'SELECT * FROM product_master WHERE sub_cat_id = '.$_SESSION['sub_cat_id'];
}else if(isset($_SESSION['category_id']) && $_SESSION['category_id'] != ''){
$sql = 'SELECT * FROM product_master WHERE category_id = '.$_SESSION['category_id'].' ORDER BY rand() LIMIT 12';
}else {
$sql = 'SELECT * FROM product_master ORDER BY rand() LIMIT 12';
}
$res = mysql_query($sql);
?>
if($res && mysql_num_rows($res) > 0): ?>
while($row = mysql_fetch_array($res)): ?>
endwhile; ?>
else: ?>
No Products Found Under this Category
endif; ?>