I had the same case as yours and I used the switch case capability of PHP, you can also use If else and nested If but in my case i can make several options for search but had to make it in different forms, each having at most two options only;
//declare variables
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'dost';
$dbname = 'db_agreements';
//connect to mysql
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
//select database
mysql_select_db($dbname);
//variables for search
$Type=$_POST["Type"];
$searchID=$_POST["txtID"];
$searchTitle=$_POST["txtTitle"];
switch ($Type) {
case "Agreements":
$result = mysql_query("SELECT agreement_id, country, title, signed, ratified, status, signatories, mode, areas, validity, effectivity, activity FROM tbl_agreement WHERE title LIKE '%$searchTitle%' ");
while($row=mysql_fetch_array($result))
{
//change date format
$d_signed="{$row['signed']}";
$d_rat="{$row['ratified']}";
$d_eff="{$row['effectivity']}";
$d_signed = strftime("%b %d, %Y" ,$d_signed);
$d_rat = strftime("%b %d, %Y" ,$d_rat);
$d_eff = strftime("%b %d, %Y" ,$d_eff);
echo "<b>Agreement ID :</b>{$row['agreements_id']} " .
"<b>Country :</b>{$row['country']} " .
"<b>Title :</b>{$row['title']} " .
"<b>Date Signed :</b> {$row['signed']}" .
"<b>Date Ratified :</b> {$row['ratified']} " .
"<b>Effectivity :</b> {$row['effectivity']} " .
"<b>Status :</b>{$row['status']} " .
"<b>Signatories :</b> {$row['signatories']} " .
"<b>modes of Cooperation :</b> {$row['modes']} " .
"<b>Areas of Concern :</b> {$row['areas']} " .
"<b>Validity :</b> {$row['validity']} " .
"<b>Activities :</b> {$row['activity']} ";
}
//}
break;
case "Protocols":
$searchID=$_POST["txtID"];
$result = mysql_query("SELECT agreement, protocol_id, title, country, modes_coop, areas_con, agreement_id FROM tbl_protocols WHERE title LIKE '%$searchTitle%' ");
while($row=mysql_fetch_array($result))
{
echo "<b>Agreement Number :</b>{$row['agreement_id']} " .
"<b>Agreement :</b>{$row['agreement']} " .
"<b>Country :</b>{$row['country']} " .
"<b>Protocol Number :</b>{$row['protocol_id']} " .
"<b>Title :</b> {$row['title']} " .
"<b>Modes of Cooperation :</b> {$row['mode_coop']} " .
"<b>Areas of Concern :</b> {$row['areas_con']} ";
}
//}
break;
case "Projects":
$searchID=$_POST["txtID"];
$result = mysql_query("SELECT project_id, title, description, rp_budget, ctrpart_budget, activities, remarks, country, protocol_id, agencies FROM tbl_projects WHERE title LIKE '%$searchTitle%' ");
while($row=mysql_fetch_array($result))
{
$agreement_id=$row["agreement_id"];
echo "<b>Country :</b>{$row['country']} " .
"<b>Protocol ID :</b>{$row['protocol_id']} " .
"<b>Project ID :</b>{$row['project_id']} " .
"<b>Title :</b> {$row['title']} " .
"<b>Description :</b> {$row['description']} " .
"<b>RP Budget :</b>{$row['rp_budget']} " .
"<b>Counter Part Budget :</b>{$row['ctrpart_budget']} " .
"<b>Activities :</b>{$row['activities']} " .
"<b>Agencies :</b>{$row['agencies']} " .
"<b>Remarks :</b> {$row['remarks']} ";
}
//}
break;
default:
$searchID=$_POST["txtSearchID"];
// else
echo "Enter Search";
}
?>
Good thing the people in our company only needs two searches for now, since i havn't learned in making more than two queries in a single form, but I guess what i did is just the same principle if your going to add more options to your search, im still trying to finish four additional options on top of the two. to the experts, any suggestions. please :D