I've got a search form that's searching a MySQL DB. I've got 3 columns that comprise a "Date": Month, Day, Year, and I need to get them searched so the user can look them up either by month or by Month/Day or Month/Day/Year, etc. The problem I'm hitting, is that I don't know how to tell the search.php form that there is more than one searchterm. I can throw in <input type="hidden" value="month"> but that would only cover 1 of the three columns.
Here is the code for the search form:
<form action="/shows/search.php" method="get">
<select name="month">
<option selected>Month
<option value="January">January
<option value="February">February
etc, etc...
</select>
<select name="day">
<option selected>Day
<option value="01">1
<option value="02">2
etc, etc...
</select>
<select name="year">
<option selected>Year
<option value="2003">2003
<option value="2004">2004
</select>
<input type="submit" value="Go">
</form>
Here is the code for the search.php:
<h1> Search Results</h1>
<?php
include("$lib/dbconnect.php");
trim($searchterm);
if (!$searchterm)
{
echo ("You havent entered any info please do so<br />");
include ("$scriptroot/searchform.php");
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
mysql_select_db("database");
$query = "select * from db_table where ".$searchtype." like
'%".$searchterm."%'";