Skip to main content
Oct 21, 2009 5:14 PM UTC
Question

how to filter results from 4 dynamic list menus depandant on how many of them are selected

I have a search page with a form with 4 list menus and 1 submit that post the results to the results page. I can create a record set that either retrieves the correct data from my database if a selection is made from all four menus Or i can create the recordset if only 3 menus have a selection or the same for 2 menus and 1 menu. However i want the user to be able to make a selection from either 1, 2, 3 or all 4 of the menus and the exact data be retrieved. At present if i try to combine the recordset using AND and ORs the results are not specific enough, for example the 4 menus are Location, Type, Price & Style if a user selects from all 4 i only want to retrieve data that matches all 4 criteria, but at the same time if the user selects only 2 of the menus the i want it to retrieve data that matches specifically those 2 variables. I´m not actually sure if i should be creating a more advanced sql query of if its the php side of things that i need to look at. This is my first dynamic site so please be aware i´m still a learner where php and sql is concerned. Please can anyone help?  

This topic is closed to new replies. Start a new post to keep the conversation going.

8 replies

Known Participant
Oct 21, 2009 8:36 PM UTC

Hiya,

I'm just doing my first dynamic site too, and am at a similar level to yourself.

Can you give us more info re the site. What software, eg Dreamweaver etc are you using, and is your server using PHP or ASP etc?

For what I've used, I amended the SQL side of things in the recordset in Dreamweaver. That way, you can test the SQL as you're setting up the recordset.

Let me know how you're going on anyway

Cheers

Andy

Translate
Oct 22, 2009 12:19 AM UTC

Hey there,

Thanks for replying,

I too am using Dreamweaver recordset, my local server is XAMPP ( apache php mysql), i´have pasted my sql recordset below to give an idea of what i´m trying to do, however this does not work as i´m trying to select the exact data based on 4 menus PRICE TYPE LOCATION and BEDS, and also want the search to work if the user only selects options from either 1, 2, 3 or 4 of the menus, with the code as it is if the user select only two options from 2 of the menus the results don´t just find (for example) all results for location AND price they find all results for the location varibale OR the price variable rather than a match for both, if you see what i mean?

Any suggestions?

SELECT trueprice,`desc`, `propid`, `bathrooms`, `photo1`, locationtable.loc, typetable.style, bedtable.`number`

FROM detailstable JOIN locationtable ON detailstable.location=locationtable.locid JOIN typetable ON detailstable.type=typetable.typeid JOIN pricetable ON detailstable.price=pricetable.priceid JOIN bedtable ON detailstable.beds=bedtable.bedid

WHERE (location=varloc AND price = varprice AND type=vartype AND beds=varbed ) OR (price=varprice AND location=varloc AND type=vartype) OR (price=varprice AND location=varloc AND beds=varbed) OR (price=varprice AND beds=varbed AND type=vartype) OR ( location=varloc AND type=vartype AND beds=varbed) OR (price=varprice AND location=varloc) OR (price=varprice AND type=vartype) OR (price=varprice AND beds=varbed) OR (type=vartype AND location=varloc) OR (type=vartype AND beds=beds) OR (location=varloc AND beds=varbed) OR (price = varprice OR beds=varbed OR type=vartype OR location=varloc)

ORDER BY detailstable.trueprice ASC

Look forward to receiving your thoughts,

Linda

Date: Wed, 21 Oct 2009 14:36:33 -0600

From: forums@adobe.com

To: linda.barker7@hotmail.com

Subject: how to filter results from 4 dynamic list menus depandant on how many of them are selected

Hiya,

I'm just doing my first dynamic site too, and am at a similar level to yourself.

Can you give us more info re the site. What software, eg Dreamweaver etc are you using, and is your server using PHP or ASP etc?

For what I've used, I amended the SQL side of things in the recordset in Dreamweaver. That way, you can test the SQL as you're setting up the recordset.

Let me know how you're going on anyway

Cheers

Andy

>

Translate
Known Participant
Oct 22, 2009 9:09 AM UTC

How is your database set up? Have you got 4 tables (PRICE, TYPE, LOCATION and BEDS) and one recordset in Dreamweaver, or have you got a recordset for each table?

Can you give me an example of how your database tables etc are set up and I'll try and set a similar one up and test it myself? From what I can see, the recordset info looks ok, but without an actual recordset to test, I can't work it out. Like I say, I'm a newbie to all this as well!

Cheers

Andy

Translate