Advance Search Query
Posted: Mon Jun 27, 2011 8:31 pm
Hi all,
I am trying to work out the best way to build a custom advance search feature and I have no idea where to start.
First thing is I have all the data in a MySQL table with assigned IDs.
Setup: I have a page with multiple checkboxes belonging to multiple groups i.e. category_1 has options 1_1, 1_2, 1_3. category_2 has options 2_1, 2_2, 2_3 and so on.
In my DB I have a record with category_1 = 1_1 and category_2 = 2_3 for example.
I know how to get the data out of the table with a simple URL i.e. http://get-records.php?category_1=1_1&category_2=2_3 for example. Now how would I get records where:
category_1 = 1_1 AND category_2 = 2_3
OR
category_1 = 1_2 AND category_2 = 2_1
Writing the SELECT statement is no problem but how would I go about writing the URL?
Basically I would like to be able to build on the URL with the current URL so:
If current URL is:
http://get-records.php?category_1=1_1&category_2=2_3
and I select another checkbox (category_1 = 1_2) I would like:
http://get-records.php?category_1=1_1&c ... gory_2=2_3
Is this possible and does this make sense? It does in my mind anyway.
I am trying to work out the best way to build a custom advance search feature and I have no idea where to start.
First thing is I have all the data in a MySQL table with assigned IDs.
Setup: I have a page with multiple checkboxes belonging to multiple groups i.e. category_1 has options 1_1, 1_2, 1_3. category_2 has options 2_1, 2_2, 2_3 and so on.
In my DB I have a record with category_1 = 1_1 and category_2 = 2_3 for example.
I know how to get the data out of the table with a simple URL i.e. http://get-records.php?category_1=1_1&category_2=2_3 for example. Now how would I get records where:
category_1 = 1_1 AND category_2 = 2_3
OR
category_1 = 1_2 AND category_2 = 2_1
Writing the SELECT statement is no problem but how would I go about writing the URL?
Basically I would like to be able to build on the URL with the current URL so:
If current URL is:
http://get-records.php?category_1=1_1&category_2=2_3
and I select another checkbox (category_1 = 1_2) I would like:
http://get-records.php?category_1=1_1&c ... gory_2=2_3
Is this possible and does this make sense? It does in my mind anyway.