I have a form which has a checkbox with three options i.e. 'A'
,'B'
and 'C'
. I need to build a SELECT
statement to get data from a database table X, for which the WHERE
clause could be WHERE field1 IN ('A','B','C')
or it could be any one of the values i.e. WHERE field1 = 'A'
etc.
I am kind of stuck as to how to proceed with the SELECT
statement.
Please let me know if any more details are required to understand the problem.
The code for my checkbox in the form:
<input type="checkbox" name="gender[]" value="Male" id="Male"> Male
<input type="checkbox" name="gender[]" value="Female" id="Female"> Female
<input type="checkbox" name="gender[]" value="Other" id="Other"> Other
The SELECT statement would basically be like :
SELECT field1,field2,field3
FROM X
WHERE field1 IN('A','B','C')
or it could be
SELECT field1,field2,field3
FROM X
WHERE field1 ='A' -- Basically this could be a single value.