Filters with PHP priority

Asked

Viewed 46 times

0

Hello,

On many web platforms, I see that there are forms, search systems, etc., where the user needs to, mark some elements, be they dropdowns, checkboxes, radios Buttons, but in some of them, regardless of whether they are empty or not, the system still filters and returns what you searched for because some do not need filling.

My curiosity is to know how the back-end is usually done in these circumstances. How is the select inside the bank? Because the only way I can imagine is a chain of ifs or switches with PHP.

Grateful.

1 answer

0

If I understood correctly, one of the ways to do this is to mount the query in PHP, save it in a string and then run. The assembly of the query can be done through text substitution. So it is possible to add or remove elements without breaking SQL syntax.

  • But save it and only be executed if any condition is established or check if the variables, whether by get or post method, are set and then apply str_replace?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.