You need to construct your sql from the variables passed from the search screen:
"any age" would require no match on the age column but age < 7 would, for instance.
"small" would require a match on the size column etc etc.
Your sql construct would look like this:
SELECT * FROM table WHERE col1 = condition1 AND col2 = condition2 AND col3 = condition3
You can add as many additional AND conditions on individual columns as are required, HOWEVER beware if your column is referenced twice with 2 seperate conditions because you would then need to use and OR
SELECT * FROM table WHERE col1 = condition1 AND col2 = condition2 AND ((col3 = condition3) OR (col3 = condition4))
When constructing your sql, you need to ensure that no empty clauses are passed ie "col3 = AND"
To do this, you should construct your sql using something along the following lines: (very simple example)
$query_start = 'WHERE ';
if ($HTTP_POST_VARS['cond1']) {
$query_array[] = "col1 = '" . $HTTP_POST_VARS['cond1'] . "'";
}
if ($HTTP_POST_VARS['cond2']) {
$query_array[] = "col2 = '" . $HTTP_POST_VARS['cond2'] . "'";
}
if ($HTTP_POST_VARS['cond3']) {
$query_array[] = "col3 = '" . $HTTP_POST_VARS['cond2'] . "'";
}
# create the query string by combining the query array using "AND" as a delimiter
if ($query_array) {
$query_string = $query_start . implode(' AND ', $query_array);
}
}
# retrieve the list
$sth = mysql_query("SELECT * FROM table $query_string")