switch statement - $sql2 default not performing
hi all
below is my switch function based on "choice" option selected (high/low)
PHP Code:
<?
$choice=$_REQUEST['choice'];
switch($choice) {
case 'high':
$sql = "select * from product_table where dealer_id=$dealer_id order by price desc LIMIT";
break;
case 'low':
$sql = "select * from product_table where dealer_id=$dealer_id order by price asc LIMIT";
break;
default :
$sql = "select * from product_table where dealer_id=$dealer_id";
break;
}
below is my code for switch function based on "sub_catg" + "choice" selected
PHP Code:
/*switch for sub categories start*/
if(isset($_REQUEST['sub_catg']))
{
$sub_catg=$_REQUEST['sub_catg'];
switch($choice) {
case 'high':
$sql2 = "select * from product_table where dealer_id=$dealer_id and sub_catg=$sub_catg order by price desc";
break;
case 'low':
$sql2 = "select * from product_table where dealer_id=$dealer_id and sub_catg=$sub_catg order by price asc";
break;
default :
$sql2 = "select * from product_table where dealer_id=$dealer_id and sub_catg=$sub_catg";
break;
}
}
/* switch for sub categories ends*/
?>
The problem :
If "choice" is not selected but "sub_catg" is selected then $sql2 default query should be peformed.
But in my case $sql default is performed.
vineet