I'm having a little difficulties getting the right data from my tables.
I have the following tables.
Costumers:
CostumerID
CostumerName
Filters:
FilterID
FilterName
FilterChoice
Choices:
ChoiceID
CosID
FiltID
The data in Choice table is ex.
ChoiceID 1 CosID24 FiltID 13
ChoiceID 2 CodID24 FiltID 25
ChoiceID 3 CosID24 FiltID 26
ChoiceID 4 CodID25 FiltID 4
ChoiceID 5 CosID26 FiltID 11
ChoiceID 6 CodID26 FiltID 25
So each costumer has more than one choice selected.
The filter then puts data in $'s ex.
$choice1='25';
$choice2='13';
Now I want to get all the costumers that has both 13 and 25 in the FiltID field.
If I type
SELECT * from Choices WHERE FiltID='$choice1'
it will get costumer 24 and 26 as it should, but if I type
SELECT * from Choices WHERE FiltID='$choice1' AND FiltID='$choice2'
it won't (ofcause) get costumer 24 as I want it to, because no posts has to numbers i row FiltID.
So how do I get it to find the CosID's that has both choices, and it shall find the both 24 and 26 if only one choice ($choice1) is selected in the filter. ?
It has to work nomatter if only $choice1 has data and $choice2+3 are empty, and when all 3 choices ex has a number stores from the filter.
best
Michael