php - Filter data from mysql by countries -


i want filter data countries dropdown menu:

<form name="filter_form" method="post" action="display_data.php"> select country: <select name="value">     <option name="country" value="au">austria</option>     <option name="country" value="be">belgium</option>     <option name="country" value="bu">bulgaria</option> </select> <input type="submit" name="btn_submit" value="submit filter" /> <?php if($_post['country'] == 'be') {        $query = mysql_query("select * think country='belgium'");   }   elseif($_post['country'] == 'au') {   $query = mysql_query("select * think country='austria'");   } else {       $query = mysql_query("select * think");   }   ?> 

the code not filter data. if can help, thanks!

avoid writing redundant code. change code below code:

<form name="filter_form" method="post" action="display_data.php"> select country: <select name="country">     <option value="au">austria</option>     <option value="be">belgium</option>     <option value="bu">bulgaria</option> </select> <input type="submit" name="btn_submit" value="submit filter" />  <?php if(isset($_post['country'])) {     switch($_post['country'])     {     case 'be' : $countryname = 'belgium';                 break;     case 'au' : $countryname = 'austria';                 break;     default : $countryname = '';               break;     }     $where = '';     if($countryname != '')     {         $where = "where country='".$countryname."'";     }        $query = mysql_query("select * think ".$where."");   } ?> 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -