0

Hi, can someone tell why or how I can perform a search using text from a drop down box -

I can search successfully using a textbox and bring back the correct search results -

But when I am using a dropdown box my search seems not to work -

what I am trying to do is search my products table by the given country name.

The problem is I think i am missing something out about the id's ?? but im not totally sure where I am going wrong.

I have a few searches like this one, so if I can get this working, I will be able to get the others working by following the same format.

Hoping someone can point me in the right direct or help me fix this -

here is the form i am using -

<form id="country" name="country" method="post" action="index.php">
   	     <select name="country" id="country" class="tb12" title="Search country">				
             <option value="England">England</option>
             <option value="USA">USA</option>    
          </select>  
            <input name="country" type="submit" id="country" class="tb11" value="Search country" title="Search by country" />
            <input type="hidden" name="country" value="by_country" />
        </form>

and here is my search

if ($_POST['country'] == "by_country") {
$queryString = "WHERE country LIKE '%$_POST[country]%' AND activated='1' ORDER BY id DESC";
    $queryMsg = "Displaying all products by $_POST[country]";
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vaultdweller123
0

your drop down and submit button has the same name, thats causing ambiguity

<select name="country" id="country" class="tb12" title="Search country">				
             <option value="England">England</option>
             <option value="USA">USA</option>    
          </select>

and

<input name="country" type="submit" id="country" class="tb11" value="Search country" title="Search by country" />
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.