title: Create Dropdown list PHP database search?
body: <p>I am trying to create a dropdown list search to search my database in PHP and my SQL. So far I have been able to create a simple text search which brings back the results needed when I type them into the search box. But I want to be able to select an option from the dropdown list instead of typing it in.</p>
  <p>Here is my search.php code...</p>
  <pre><code>&lt;?php
  
  mysql_connect (&quot;localhost&quot;, &quot;root&quot;,&quot;&quot;)  or die (mysql_error());
  mysql_select_db (&quot;schoolsni&quot;);
  
  $term = $_POST['term'];
  
  $sql = mysql_query(&quot;SELECT * FROM  product WHERE  model LIKE '%$term%'&quot;);
  
  while ($row = mysql_fetch_array($sql)){
      echo 'Product ID '.$row['product_id'];
      echo '&lt;br/&gt; Model: '.$row['model'];
      echo '&lt;br/&gt; quantity: '.$row['quantity'];
      echo '&lt;br/&gt;&lt;br/&gt;';
      }
  
  ?&gt;
  </code></pre>
  <p>And here is my HTML code...</p>
  <pre><code>&lt;div class=&quot;UFcol1&quot;&gt;
      &lt;form action=&quot;search.php&quot; method=&quot;post&quot;&gt;
          &lt;select name=&quot;term&quot;&gt;
      &lt;option value=&quot;product&quot;&gt;product&lt;/option&gt;
      &lt;option value=&quot;product1&quot;&gt;product 1&lt;/option&gt;
      &lt;option value=&quot;product3&quot;&gt;product 3&lt;/option&gt;
      &lt;option value=&quot;product4&quot;&gt;product 4&lt;/option&gt;
      &lt;/select&gt;
          &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>