I have a collection of games and now I want to filter them with a SQL Query. I have a checkboxes formular divided by categories "numbers of players", "type of game", "duration" etc. So my SQL query needs to combine checkboxes within a categorie and exclude across the category.
For example: If someone checks a game for "1-5 Players" and "5-10 Players" which lasts for "5 Minutes" which is also "Ball Game" and "Water Game" I want to output all the Games which are number_of_players "1-5 Players" OR "5-10 Players" AND duration = "5 Minutes" AND type_of_game = "Ball Game" OR "Water Game"
But as well, there's the possibility to check nothing. Example: If someone doesn't check anything at all for the duration but checks "5 Minutes" as well as "Ball Game" and "Water Game" I want to output all the games which are duration = "5 Minutes" AND type_of_game = "Ball Game" OR "Water Game".
I think I have to add some sort of priority to the categories. The first selected category always defines the "mass" and the other checkboxes limits this mass.
Aucun commentaire:
Enregistrer un commentaire