Or another way:
// Populate the input vars...
$hair = 'golden';
$eyes = 'blue';
$table = 'test';
// Your array of mysql column names => variable names
$vars = array('hair'=>'hair','eye'=>'eyes','bodyType'=>'bodyType','ethnicity'=>'ethnicity','lookingFor'=>'lookingFor');
// Setup an array to hold whatever is going in the db
$sqlArray = array();
// Loop through each variable (using the double $), if not empty... it will be added to the query
foreach($vars as $mysql=>$input) {
if(!empty($$input) && $$input!='Any')
$sqlArray[] = $mysql . ' = "' . $$input . '"';
}
// Count the number of elements that will go in the query and properly handle them
if(count($sqlArray)==1)
$query = "select * from {$table} where {$sqlArray[0]}";
else if(count($sqlArray)>1)
$query = "select * from {$table} where ".implode($sqlArray,' and ');
else
$query = "select * from {$table}";
// Show the query ... you would normally run the mysql_query here
echo $query;
Anyways. What errors are you getting?