[Solved] Search query using php and mysql [closed]


Try this:

$query = "select * from table_name where 1 ";

if(!empty($_POST['field1']) ) {
   $query .= " AND field1 like '".trim($_POST['field1'])."'";
}
if(!empty($_POST['field2'])) {
   $query .= " AND field2 like '".trim($_POST['field2'])."'";
}
// and so on
$result = mysql_query($query);

1

solved Search query using php and mysql [closed]