Below is my code...
I am trying to create search with multiple parameters in php pdo....with Multiple if else condition...in singlw query...
plz help ...to make this...how can i do this with php pdo...
  <?php
$db=new PDO('mysql:host=localhost;dbname=circulation_scheme_prepaid','root','');
if(isset($_POST['Submit']))
{   
$result=$db->prepare('SELECT * FROM receipt_entry WHERE');
    if($_POST['book']!='')
    {
         $result->bindParam(':book',$_POST['book']);
    }    
$result->execute(); 
$data = $result->fetchAll();
}
?>
I nned to make above code like this..
<?php
require_once("includes/config.php");
if(isset($_POST['search']))
{   
    $sql = "SELECT * FROM properties WHERE";
    if($_POST['location']!='')
    {
        $location = $_POST['location'];
        $sql .= " location = '$location' AND";
    }
    if($_POST['purpose']!='')
    {
        $purpose = $_POST['purpose'];
        $sql .= " purpose = '$purpose' AND";
    }
    $sql = substr($sql, 0 ,-3); 
$query = mysql_query($sql);
while($row = mysql_fetch_array($query,MYSQL_ASSOC))
        {
            $rows[] = $row;
        }
}
?>
 
    