The most problematic lines of your code (regarding filtering) are probably the following two:
$('.row >div[data-category=' + this.value + ']').show(); $('.row >div[brand=' + this.value + ']' ).show();
Here you explicitly indicate " show all divs where data-category = value and show all divs where brand = value".
What you really want is to " show all divs where data-category = value and brand = value".
You might want to try something like
$('input[type="checkbox"]:checked').each(function() { $('.row >div[data-category=' + this.value + '][brand=' + this.value + ']').show(); });
Also, some additional fixes in your code (not related to your filtering issue):
1) Indeed the ability to directly enter sql in
$sql = "SELECT * FROM products WHERE category='".$_GET["category"]."'";
2) You attach the click event to each in the DOM, even if the flags are not intended for filtering, it would also be more appropriate to use the change event instead of the click event (you can also change the state of the flag using the keyboard, and not just with a mouse click)
$('input[type="checkbox"]').click(function() {
Mikk
source share