Question
Search multiple form parameters
I have created a database that contains student information,
and I have created a search function such that the database can be
queried for things like the student's age, gender, and ethnicity.
It all works great when the query contains age AND gender AND ethnicity, however I want the form to work if one or more of the fields is left blank. I am using DW8, php, and SQL.
So far, my SQL is:
SELECT *
FROM studentinfo
WHERE studentinfo.gender = 'colname' AND studentinfo.state = 'res'
While my variables are:
Name: res
Default value: studentinfo.state
Runtime value: $_POST['select3']
Name: colname
Default value: studentinfo.gender
Runtime value: $_POST['select']
Select3 and select are form menues. I have read some posts about using !empty in place of isset, but it does not seem to work in my code. Thank you in advance for any help/ideas.
It all works great when the query contains age AND gender AND ethnicity, however I want the form to work if one or more of the fields is left blank. I am using DW8, php, and SQL.
So far, my SQL is:
SELECT *
FROM studentinfo
WHERE studentinfo.gender = 'colname' AND studentinfo.state = 'res'
While my variables are:
Name: res
Default value: studentinfo.state
Runtime value: $_POST['select3']
Name: colname
Default value: studentinfo.gender
Runtime value: $_POST['select']
Select3 and select are form menues. I have read some posts about using !empty in place of isset, but it does not seem to work in my code. Thank you in advance for any help/ideas.
