ESeufert Posted August 6, 2007 Share Posted August 6, 2007 I'm putting together a form that will allow users to pare down a list of users based on their criteria. This has to be boolean, though, and I'm having a hard time logically putting it together. The form looks like this: User Hair Color <select> Brown </select> <select> Blonde </select> <checkbox>AND</checkbox><checkbox>OR</checkbox> User Eye <select> Blue </select> <select> Hazel </select> <checkbox>AND</checkbox><checkbox>OR</checkbox> User Height <select> Short </select> <select> Tall </select> <checkbox>AND</checkbox><checkbox>OR</checkbox> So ultimately a person could have selected that they want to see a list of users that have: Brown Hair OR Blonde Hair AND Blue Eyes OR Tall OR Short Is there an easy way to do this? Obviously these aren't the real criteria. So basically, I've got 5 sections, all of which contain 5 select boxes with possible criteria. Each of these criteria has an AND/OR next to it. Between each section is another AND/OR set of checkboxes. So within each section you've got AND/OR and then between sections there's an AND/OR. The data is stored in the database like this: userHairColorItems userID = 1 hairColorID = 2 userHeightItems userID = 1 userHeightID = 1 Where hairColorID = 2 would be Blonde, userHeightID = 1 would be short, etc. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/63577-boolean-criteria-search/ Share on other sites More sharing options...
Barand Posted August 6, 2007 Share Posted August 6, 2007 You could have, for this Brown Hair OR Blonde Hair AND Blue Eyes OR Tall OR Short WHERE ( (HairColorID = 1) OR (HairColorID = 2)) AND (eyeColor = 1) AND ((userHeightID = 1) OR (userHeightID = 2)) but it's easier to use the IN syntax instead of multiple ORs WHERE ( HairColorID IN (1,2) ) AND ( eyeColor = 1 ) AND ( userHeightID IN (1,2) ) Quote Link to comment https://forums.phpfreaks.com/topic/63577-boolean-criteria-search/#findComment-316854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.