How to build an SQL query for multiple form fields..?
Posted on 2009-05-20
I have a mySQL database that has about 65 or so fields, each related to an input field on an HTML form. Many of the fields are checkboxes (arrays) on the HTML field, which I have "imploded" into comma separated strings for the database. I have been using "strpos" in order to check if a value exists and display the desired results. (Overcoming the checkbox problem was a big obstacle for me....)
I would like to be able to search my mySQL database, on a variety of different criteria. So my search form would have the same fields (almost) as my input form, and I could search on text value(s) and on checkbox value(s).
My problem is how to build an SQL statement that searches multiple fields for multiple values. All the examples I've come across show only simple SQL examples. If anyone can give any suggestions or links to a good tutorial that would be great.