ComboBox to choose search field (problem in if statement)
Posted: Thu Oct 23, 2008 4:33 am
Hi guys,
I have a little problem... I created a combo box with two option in a form(search.php):
this is just part of the page code:
Now, in the page results.php, that is called and the user chooses to search in the form search.php I want to search by Player ou by class (the 2 combobox options).
So I have two different querys (both work correctly), but the problem is the if...else statement... I tried many things but I thing it should be something like this:
I now this isn't it... But I can't find a way to retrieve the option in the combobox.... please anyone can point me in the right direction?
Many thanks in advance
I have a little problem... I created a combo box with two option in a form(search.php):
this is just part of the page code:
Code: Select all
<form action="results.php" name="search" method="post">
Choose Search Type:<br />
<select name="searchtype">
<option value="Name">player</option>
<option value="Class">Class</option>
</select>
<br />
Enter Search Term:<br />
<input name="searchterm" type="text">
<br />
<input type="submit" name="search" value="Search">
</form>
Now, in the page results.php, that is called and the user chooses to search in the form search.php I want to search by Player ou by class (the 2 combobox options).
So I have two different querys (both work correctly), but the problem is the if...else statement... I tried many things but I thing it should be something like this:
Code: Select all
IF (!$searchtype = 'Class')
{
$query = "SELECT * FROM player JOIN classes ON player.Classe = classes.ClasseID WHERE classes.Nome LIKE '%".$searchterm."%'";
$result = $db->query($query);
bla bla bla...
}
else
{
$query = "select player.Nome,player.Classe,player.EXP from player where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);
bla bla bla...
};
Many thanks in advance