Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Search multiple form parameters

New Here ,
Jun 14, 2006 Jun 14, 2006
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.
TOPICS
Server side applications
224
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2006 Jun 14, 2006
Figured it out! Followed dtgolder's post more closely. Thanks to those who helped dtgolder and especially dtgolder.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2006 Jun 15, 2006
LATEST
Well it seems as though I can only get the solution from dtgolder to work sporadically. When I add a third variable with the !empty in place of isset, the results page returns no values. When I then remove the third variable, the search no longer works. Is !empty the right way to go about this? Thank you for your help!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines