?>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='index.php?cat=' + val ;
}
function reload3(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
var val2=form.subcat.options[form.subcat.options.selectedIndex].value;
var val3=form.subcat3.options[form.subcat3.options.selectedIndex].value;
self.location='index.php?cat=' + val + '&cat3=' + val2 + '&cat4=' + val3;
}
</script>
<?
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT category,cat_id FROM advance_filter_category order by category");
///////////// End of query for first list box////////////
/////// for second drop down list we will check if category is selected else we will display all the brand/////
$cat=$_GET['cat']; // This line is added to take care if your global variable is off
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT brand,brand_id FROM advance_filter_brand where cat_id=$cat order by brand");
}else{$quer=mysql_query("SELECT DISTINCT brand,brand_id FROM advance_filter_brand order by brand"); }
////////// end of query for second brand drop down list box ///////////////////////////
/////// for Third drop down list we will check if brand is selected else we will display all the type/////
$cat3=$_GET['cat3']; // This line is added to take care if your global variable is off
if(isset($cat3) and strlen($cat3) > 0){
$quer3=mysql_query("SELECT DISTINCT type,type_id FROM advance_filter_type where brand_id=$cat3 order by type");
}else{$quer3=mysql_query("SELECT DISTINCT type,type_id FROM advance_filter_type order by type"); }
////////// end of query for third type drop down list box ///////////////////////////
/////// for forth drop down list we will check if type is selected else we will display all the model/////
$cat4=$_GET['cat4']; // This line is added to take care if your global variable is off
if(isset($cat4) and strlen($cat4) > 0){
$quer4=mysql_query("SELECT DISTINCT model,model_id FROM advance_filter_model where type_id=$cat4 order by model");
}else{$quer4=mysql_query("SELECT DISTINCT model,model_id FROM advance_filter_model order by model"); }
////////// end of query for forth model drop down list box ///////////////////////////
echo "<form action='index.php' method='post' name='adv_search'>
<input type='hidden' name='page' value='shop.browse' />
<input type='hidden' name='option' value='com_virtuemart' />
<input type='hidden' class='inputbox' name='Itemid' value='<?php echo $Itemid; ?>' />";
////////// Starting of first drop downlist /////////
echo "<select class='inputbox' name='cat' onchange=\"reload(this.form)\"><option value=''>== Select Category ==</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}
else{echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////
////////// Starting of second drop downlist /////////
echo "<select class='inputbox' name='subcat' onchange=\"reload3(this.form)\"><option value=''>== Select Brand ==</option>";
while($noticia = mysql_fetch_array($quer)) {
if($noticia['brand_id']==@$cat3){echo "<option selected value='$noticia[brand_id]'>$noticia[brand]</option>"."<BR>";}
else{echo "<option value='$noticia[brand_id]'>$noticia[brand]</option>";}
}
echo "</select>";
////////////////// This will end the second drop down list ///////////
////////// Starting of third drop downlist /////////
echo "<select class='inputbox' name='subcat3' onchange=\"reload3(this.form)\"><option value=''>== Select Type ==</option>";
while($noticia3 = mysql_fetch_array($quer3)) {
if($noticia3['type_id']==@$cat4){echo "<option selected value='$noticia3[type_id]'>$noticia3[type]</option>"."<BR>";}
else{echo "<option value='$noticia3[type_id]'>$noticia3[type]</option>";}
}
echo "</select>";
////////////////// This will end the third drop down list ///////////
////////// Starting of forth drop downlist /////////
echo "<select class='inputbox' name='subcat4'><option value='' >== Select Model ==</option>";
while($noticia4 = mysql_fetch_array($quer4)) {
echo "<option value='$noticia4[model_id]'>$noticia4[model]</option>";
}
echo "</select>";
////////////////// This will end the forth drop down list ///////////