Search DB with multiple criteria but when date is not selected no results are shown
<p>I have a db search to display results based on selected criteria, one of the criteria is a date range, plus 3 other criteria.The searching works well, I can search by date range only to display all results or I can search a date range and add 1, 2 or all 3 of the other variables..however If I leave date range out no results are displayed.  Using mysql db.</p>

<pre><code>Search page::

$term1 = $_REQUEST['term1'];
$term2 = $_REQUEST['term2'];
$term3 = $_REQUEST['term3'];
$term4 = $_REQUEST['term4'];
$term5 = $_REQUEST['term5'];

$terms= '&amp;term1='.$term1 . '&amp;term2='.$term2 . '&amp;term3='.$term3 . '&amp;term4='.$term4 . '&amp;term5='.$term5;

$limit=15;

$sql ="SELECT * FROM ircb WHERE cdate BETWEEN '$term2' AND '$term3' AND staff  LIKE '%$term1%'  AND item LIKE '%$term4%' AND service LIKE '%$term5%' ORDER BY id DESC LIMIT $start_from, 15";


$rs_result = mysql_query ($sql);
$num_rows = mysql_num_rows($rs_result);
$query = mysql_query("SELECT * FROM ircb WHERE cdate BETWEEN '$term2' AND '$term3' AND staff  LIKE '%$term1%'  AND item LIKE '%$term4%' AND service LIKE '%$term5%'"); 
$number=mysql_num_rows($query); 
</code></pre>

<p>Term 2 and term 3 are the date range terms entered from a date picker and put in proper format of 000-00-00, I assume the issue is the WHERE statement
thanks</p>
