Hi,
I have a page with a big number of checkboxes (right now around 20). A visitor to this page is supposed to check them (as many as he/she wishes) and perform a search on the database for all items that match his choice.
I use the following code:
<input type="checkbox" name="section1" value="hardware">
<input type="checkbox" name="section2" value="software">
<input type="checkbox" name="section3" value="multimedia">
and so on...
In the database I have two columns "e_mail" and "section". The first column is self-explanatory. In the "section" column all data is separated by comma e.g. one field can contain "hardware, multimedia" and another "software, multimedia".
Then the searching code:
$result_user = mysql_query("SELECT DISTINCT (e_mail) FROM test WHERE (section LIKE '%$section1%' OR section LIKE '%$section2%' OR section LIKE '%$section3%' OR section LIKE '%$section4%' OR section LIKE '%$section5%' OR section LIKE '%$section6%' OR section LIKE '%$section7%' OR section LIKE '%$section8%' OR section LIKE '%$section9%' OR section LIKE '%$section10%')");
The idea is to list all e_mails where at least one item from the "section" field is true. For some reason the query displays all e-mails regardless of the checkboxes that were checked.
Any idea?
Witold