Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Form to Query and back again
01-28-2010, 04:33 PM #1
- Join Date
- Jan 2010
- Thanked 0 Times in 0 Posts
Form to Query and back again
So, I have this database, and I want to give the user a form to search by all or some of the fields. The fields on the form are of a variety of types (checkboxes, dropdown boxes, etc). What I want is the ability for the user to setup search criteria and then have it be saved to the database (possibly in the form of a query) and then of course, they will have the ability to edit their saved search (which would turn the query back into the form elements they picked/didn't pick). I hope that makes sense. I'm sure this has been done 1,000's of times if not more. I'm looking for suggestions as to the most efficient way to do this. I can make a large amount of IF's etc and build the query.. and then write code to turn it back. but I'm thinking some type of loop or something would be better so that I'm not hard-coding each option?
01-28-2010, 06:20 PM #2
- Join Date
- Apr 2009
- Thanked 20 Times in 20 Posts
I suppose the most apparent way to do this is to have a table that stores the saved criteria associated with the user. Something like this example structure:
[UserID] = 123
[CheckBoxGroup1] = 0010010 (meaning like if there are 7 checkboxes, 1 means checked, 0 means not checked)
[CheckBoxGroup2] = 1011101
[DropdownList1] = 3 (meaning 4th selection in the dropdown list)
[DropdownList2] = 0
So, the server-side logic would read and decode this table for the given user and have the page render with the saved criteria. Makes sense?