You can put multiple items together in switch
, so instead of having "high" and "default" with the same action, you can just do
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id order by price asc";
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id and catg = 'medium'";
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id order by price desc";
Anyway, I think I'd use this
But that's just because I don't like switch (too easy to forget a break leaving you debugging for hours on end because you don't spot the omission ...), and like arrays
$extra = array(
'low' => 'order by price asc',
'medium' => 'and catg = "medium"',
'high' => 'order by price desc'
$sql = 'SELECT * FROM product_table where dealer_id='.intval($dealer_id) . ( isset($extra[$choice])? (' '.$extra['choice']) : '' );
while($row = mysql_fetch_array($result))
// results will be displayed here which is approx 50 lines code.
As you can see, I don't like double quotes either