Hello all,
I have a hidden field in an HTML form that selects one of several fields in a database. These fields indicate whether or not a store carries a certain line of merchandise. These fields, in the database are "checked" or not. The database contains retailer information (It's a store locator). This all works great.
My problem is that in one (newly defined) instance, I need to return a result based an either or situation. (one line of merchandise, or the other)
Can this be done with the HTML form?
Here is the form -- the search code will follow:
<form method=get action=customer_search.php3>
<input type="hidden" name="occ" value="checked">
<input type="hidden" name="occ_fl" value="checked">
<tr>
<td align="right" bgcolor="#dddddd"><select name="state">
<OPTION VALUE="none">Select State (US & Can)
<OPTION VALUE="AL"> Alabama
<OPTION VALUE="AK"> Alaska
<OPTION VALUE="AZ"> Arizona
etc....
The search statement which the form sends to: (I need to return all "occ" and "occ_fl" info when only "occ' is selected)(in the database - only one or the other is ever "checked")
$searchStmt = "SELECT * FROM $tableName WHERE inactive <> 'checked' AND " ;
if ($state)
$searchStmt .= "state LIKE '%$state%' AND " ;
if ($country)
$searchStmt .= "country LIKE '%$country%' AND " ;
if ($region)
$searchStmt .= "region LIKE '$region' AND " ;
if ($occ)
$searchStmt .= "occ LIKE '$occ' AND " ;
if ($occ_fl)
$searchStmt .= "occ_fl LIKE '$occ_fl' AND " ;
if ($vis)
$searchStmt .= "vis LIKE '$vis' AND " ;
if ($jim)
$searchStmt .= "jim LIKE '$jim' AND " ;
if ($alv)
$searchStmt .= "alv LIKE '$alv' AND " ;
if ($laz_b)
$searchStmt .= "laz_b LIKE '$laz_b' AND " ;
if ($laz_bm)
$searchStmt .= "laz_bm LIKE '$laz_bm' AND " ;
if ($inactive)
$searchStmt .= "inactive LIKE '$inactive' AND " ;
$stmt = substr($searchStmt, 0, strlen($searchStmt)-4) ;
$stmt .= "ORDER BY region, country, state, city, store";
Thanks - Mike Acklin