there is a sneaky trick to set up your where clause using a quirk of SQL
PHP Code:
$WhereClause = " where 1=1";
if (abooleancondition)
{ $WhereClause .= " and anumericcolumn = ".$anumericvalue;
}
if (anotherbooleancondition)
{ $WhereClause .= " and astringcolumn = '".$astringcolumn."'";
}
by using where 1=1 means you alwasy have something in your where clause, but it doesn't affect row selection.
then add your if statements to build the fully formed (or not) where clause