php - How can i filter and echo data from multiple dropdown? -
i'm having dificulties in filtering , echo data multiple dropdown. can help? kinda lost here.
i want filter database data corresponding each dropdown...
i have following html code:
<form name="campsite_search" action="index.php" method="get"> shedding</br > <select name="shedding" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >grooming requirements</br > <select name="grooming requirements" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >exercise requirements</br > <select name="exercise requirements" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >biddabilty</br > <select name="biddabilty" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >prey drive</br > <select name="prey drive" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >barking/vocal</br > <select name="barking/vocal" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select> </br >drive</br > <select name="drive" class="input"> <option value="all">all</option> <option value="low">low</option> <option value="moderate">moderate</option> <option value="high">high</option> </select>
and following php:
<?php $shedding = $db->escapesimple($_get['shedding']); $grooming = $db->escapesimple($_get['grooming requirements']); $exercise = $db->escapesimple($_get['exercise requirements']); $biddabilty = $db->escapesimple($_get['biddabilty']); $prey = $db->escapesimple($_get['prey drive']); $barking = $db->escapesimple($_get['barking/vocal']); $drive = $db->escapesimple($_get['drive']); $filter = ""; if($shedding !== 'all'){ $filter .= "shedding ='".$shedding."'"; } if($grooming !== 'all'){ if(isset($shedding)&&($shedding !== 'all')){ $filter .= " , "; } $filter .= "grooming <='".$grooming."'"; } if($exercise !== 'all'){ if(isset($grooming)&&($grooming !== 'all')||isset($shedding)&&($shedding !== 'all')){ $filter .= " , "; } $filter .= "exercise <='".$exercise."'"; } if($biddabilty !== 'all'){ if(isset($exercise)&&($exercise !== 'all')||isset($shedding)&&($shedding !== 'all')||isset($grooming)&&($grooming !== 'all')){ $filter .= " , "; } $filter .= "biddabilty '%".$biddabilty."%'"; } if($prey !== 'all'){ if(isset($biddabilty)&&($biddabilty !== 'all')||isset($exercise)&&($exercise !== 'all')||isset($shedding)&&($shedding !== 'all')||isset($grooming)&&($grooming !== 'all')){ $filter .= " , "; } $filter .= "prey ='".$prey."'"; } if($barking !== 'all'){ if(isset($prey)&&($prey !== 'all')||isset($biddabilty)&&($biddabilty !== 'all')||isset($exercise)&&($exercise !== 'all')||isset($shedding)&&($shedding !== 'all')||isset($grooming)&&($grooming !== 'all')){ $filter .= " , "; } $filter .= "barking ='".$barking."'"; } if($drive !== 'all'){ if(isset($barking)&&($barking !== 'all')||isset($prey)&&($prey !== 'all')||isset($biddabilty)&&($biddabilty !== 'all')||isset($exercise)&&($exercise !== 'all')||isset($shedding)&&($shedding !== 'all')||isset($grooming)&&($grooming !== 'all')){ $filter .= " , "; } $filter .= "drive ='".$drive."'"; } //print_r($filter); $rs = $a->select($view,$filter,$order,$offset,$limit);
?>
Comments
Post a Comment