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]";

The select has the same name as your hidden input... That's what's messing it up.

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" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.