Question
SQL query to filter database records with checkboxes
Hello,
I am creating a website results page (in Macromedia Dreamweaver) that yields records from my database depending on what checkboxes a user checks on the search page. I am using a MS Access database and Coldfusion.
Basically, my database has a field for each checkbox I have on my search page. In my database, these checkbox fields are populated as "True" or "False", correlating to whether the checkbox is checked, or unchecked. I only want database records to appear that correlate to the checkboxes checked.
I would like the results page to show all records that have false fields in the db, have true fields in the db that the user has checked, and false db fields that the user checked as true.
For example... say there are 3 checkboxes on my search page: checkbox1, checkbox2, checkbox3.
ID checkbox1 checkbox2 checkbox3
1 TRUE TRUE TRUE
2 TRUE FALSE TRUE
3 FALSE FALSE TRUE
4 TRUE TRUE FALSE
5 FALSE FALSE FALSE
Say the user checks checkbox1 and checkbox2, and leaves checkbox3 unchecked. The records returned would be: 4 and 5.
So since the TRUES in the db were checked as TRUE on the search page, record 4 was returned. The False for checkbox3 doesn't matter since this field would be satisfied regardless if the user checked it as true or false. Record 5 is returned for the same reason.
Records 1, 2, and 3 are not returned since they require a TRUE value entered by the user for checkbox3.
How can I create a recordset in Dreamweaver to do this? I assume I must use the "Advanced" section of the recordset wizard, or simply write the SQL code by hand. Please let me know how I can proceed.
Thanks!
I am creating a website results page (in Macromedia Dreamweaver) that yields records from my database depending on what checkboxes a user checks on the search page. I am using a MS Access database and Coldfusion.
Basically, my database has a field for each checkbox I have on my search page. In my database, these checkbox fields are populated as "True" or "False", correlating to whether the checkbox is checked, or unchecked. I only want database records to appear that correlate to the checkboxes checked.
I would like the results page to show all records that have false fields in the db, have true fields in the db that the user has checked, and false db fields that the user checked as true.
For example... say there are 3 checkboxes on my search page: checkbox1, checkbox2, checkbox3.
ID checkbox1 checkbox2 checkbox3
1 TRUE TRUE TRUE
2 TRUE FALSE TRUE
3 FALSE FALSE TRUE
4 TRUE TRUE FALSE
5 FALSE FALSE FALSE
Say the user checks checkbox1 and checkbox2, and leaves checkbox3 unchecked. The records returned would be: 4 and 5.
So since the TRUES in the db were checked as TRUE on the search page, record 4 was returned. The False for checkbox3 doesn't matter since this field would be satisfied regardless if the user checked it as true or false. Record 5 is returned for the same reason.
Records 1, 2, and 3 are not returned since they require a TRUE value entered by the user for checkbox3.
How can I create a recordset in Dreamweaver to do this? I assume I must use the "Advanced" section of the recordset wizard, or simply write the SQL code by hand. Please let me know how I can proceed.
Thanks!
