the single fields and checkboxes are quite straightforward. you have a key and a value in the $_POST/$_GET array.
$source = array_filter($_POST, /* filter function */);
$conditions = array();
foreach ($source as $field => $value)
// for queries
$conditions = $field . " = " . sql_escape($value);
// for (PDO) prepared statements
$conditions = $field . " = :" . $field;
$where = " WHERE " . implode(" AND ", $conditions);
for the between statements you need to do a conditional test, whether they are to be used like the others or if you need to code them as BETWEEN statement.