Page 1 of 1

ComboBox to choose search field (problem in if statement)

Posted: Thu Oct 23, 2008 4:33 am
by Dieneces
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:

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...
    };
 
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

Re: ComboBox to choose search field (problem in if statement)

Posted: Thu Oct 23, 2008 4:39 am
by papa
IF (!$searchtype == 'Class')

Re: ComboBox to choose search field (problem in if statement)

Posted: Thu Oct 23, 2008 4:51 am
by Dieneces
omg.... Now I feel ashamed.... worst than simple... lol


thanks for the quick reply ;)

Re: ComboBox to choose search field (problem in if statement)

Posted: Thu Oct 23, 2008 4:52 am
by papa
np :drunk: