Skip to content
Advertisement

Best way to use multiple URL paramemetrs for advacned filtering with PHP?

I wonder if there is a “simple” PHP solution to create multiple URL parameters. Until now I am able to create a “one click” filter like this:

JavaScript

and then:

JavaScript

This works great as a “one click” URL parameter for filtering! I like this simple solution to do things with URL parameters, but can’t figure out how to do something similar so i can give the option to users to select multiple parameters, like brand1, brand2, year 2021 and more.

I would prefer this to work like this: If users clicks brand1 filter then instantly reload page and show brand1 products, after if also clicks brand2 then show also brand1 and brand2 products. If users clicks again brand1 remove brand1 from filtering.

Advertisement

Answer

Make the filter parameter a comma-delimited list of filters. Then combine the existing value of $_GET['filter'] with the filter for that link.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement