Search mysql database using multiple terms utilizing drop menu for some
<p>I have multi field database, some variables are constant, they are selected using a drop menu, some variables are free entry. I want to search the database and find count of rows containing a combination of the selected terms, it works for the most part but if I use more than 2 drop menus for selection it seems to stop working: Form search:</p>

<pre><code>&lt;form  action="search2.php" method="post"&gt;
&lt;p&gt;
Name: &lt;input type="text" name="term1" style="background-color:#FFFF11"&gt;
&lt;br /&gt;
&lt;br /&gt;

Dept.: &amp;nbsp;&lt;input type="text" name="term4" style="background-color:#FFFF11"&gt;
&lt;br /&gt;
&lt;br /&gt;

Month: &lt;select name="term2" style="width:65px;  color: black;background-color:#FFFF11"&gt;
&lt;option value="" style="background-color: #FFFF11;"&gt;...&lt;/option&gt;
&lt;option value="Jan" style="background-color: #FFFF11;" &gt;Jan&lt;/option&gt;
&lt;option value="Feb" style="background-color: #FFFF11;"&gt;Feb&lt;/option&gt;
&lt;option value="Mar" style="background-color: #FFFF11;"&gt;Mar&lt;/option&gt;
&lt;option value="Apr" style="background-color: #FFFF11;" &gt;Apr&lt;/option&gt;
&lt;option value="May" style="background-color: #FFFF11;"&gt;May&lt;/option&gt;
&lt;option value="Jun" style="background-color: #FFFF11;"&gt;Jun&lt;/option&gt;
&lt;option value="Jul" style="background-color: #FFFF11;" &gt;Jul&lt;/option&gt;
&lt;option value="Aug" style="background-color: #FFFF11;"&gt;Aug&lt;/option&gt;
&lt;option value="Sep" style="background-color: #FFFF11;"&gt;Sep&lt;/option&gt;
&lt;option value="Oct" style="background-color: #FFFF11;" &gt;Oct&lt;/option&gt;
&lt;option value="Nov" style="background-color: #FFFF11;"&gt;Nov&lt;/option&gt;
&lt;option value="Dec" style="background-color: #FFFF11;"&gt;Dec&lt;/option&gt;
&lt;/select&gt;
&lt;br /&gt;
&lt;br /&gt;
Year: &amp;nbsp;&amp;nbsp;&lt;select name="term3" style="width:65px;  color: black;background-color:#FFFF11"&gt;
&lt;option value="" style="background-color: #FFFF11;"&gt;...&lt;/option&gt;
&lt;option value="2010" style="background-color: #FFFF11;" &gt;2010&lt;/option&gt;
&lt;option value="2011" style="background-color: #FFFF11;"&gt;2011&lt;/option&gt;
&lt;option value="2012" style="background-color: #FFFF11;"&gt;2012&lt;/option&gt;
&lt;/select&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;/p&gt;

&amp;nbsp;&amp;nbsp;&lt;input class="button" type="submit" name="submit" value="Submit"&gt;
&lt;/form&gt;
</code></pre>

<p>Search Code:</p>

<pre><code>&lt;?php

include "db.inc.php";
$term1 = $_POST['term1'];
$term2 = $_POST['term2'];
$term3 = $_POST['term3'];
$term4 = $_POST['term4'];
$sql ="SELECT * FROM fixes WHERE tech  LIKE '%$term1%' AND date LIKE '%$term2%' AND date LIKE '%$term3%' AND dept LIKE '%$term4%'";


$rs_result = mysql_query ($sql);
$num_rows = mysql_num_rows($rs_result);
$query = mysql_query("SELECT * FROM fixes WHERE tech  LIKE '%$term1%' AND date LIKE '%$term2%' AND date LIKE '%$term3%' AND dept LIKE '%$term4%'"); 
$number=mysql_num_rows($query); 
?&gt;
</code></pre>

<p>If I decide to use drop menu for dept, using same format above it stops working, perhpas there is a better way altogether? thanks</p>
