title: php pdo prepare statement dynamic filter
body: <p>I want to use simple filter with pdo statement.  Previously I was using the below code.</p>
  
  <pre><code>$sql = "select * from cities where 1 ";
  $city = $_REQUEST['city_name'];
  if($city!=""){
     $sql = $sql. " and name ='".$city."'";
  
   } 
   $country = $_REQUEST['country_name'];
  if($country!=""){
     $sql = $sql. " and country_name ='".$country."'";
  
   } 
  
  $result= mysql_query($sql);
  </code></pre>
  
  <p>I want to use filter if name or country name does not come , it should display all result , If name is selected there only city name result will come. If country is selected then country will appply otherwise country filter will not apply.</p>
  
  <p>Now I want to use same with pdo prepared statement but I am not getting how to create it.</p>
  
  <pre><code>$db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password');
  </code></pre>