Hi,
i don't know exactly what you want, but i expect, that you want to use the value of several input fields combined in just one select statement, like searching for a person with a specific nickname and a photo. Am i right? If i am, here it is, how i would do it.
Give all your input fields the specific name of the columnname in your database.
Use the array functionality of php. Declare your input fields like the following
<input type="text" name="fields[nickname]" value="<?=$fields['nickname']?">. When you do this, you can use it like an normal array in the script after pressing submit.
if you have done that, you can walk throug the array with an loop like: while(list($k,$v)=each($fields)), where $k is the name of your databaserow and $v is its possible value.
The good thing about it is, that you dont have to care about the names of your databasecolumns, when building your SQL-statement/s, and you do avoid code like
if(isset($nickname))...
It makes the code much shorter.
If you want do do something special, like want to look if the age is between x and y you can set the value of the html to ' x and y'
like <option value="18 and 25">18 - 25</option>
and use this directly in your statement:
"where age between ".$fields['age']
To avoid, using to many string concatenations and putting all of your search criterias together in a loop like:
while(...){
............
$sql.=...;
}
i normaly use the following kind:
$sql="select * from .... where ";
while(list($k,$v)=each($fields)){
switch($k){
case 'age':
$where[]=$k.' between '.$v;
break;
default:
$where[]=$k."='".$v."'";
}
}
$sql.=implode(' AND ',$where);
This put's all your criterias together and concats them by using 'AND'.
The result is an statement like this:
....where age between x and y AND nickname='paul' AND....
Hope i could help a little bit.
silver....