I'm trying to find the best way to make "filtering" of my data. Filters are set by input fields on front end, and based on that filters (inputs) i need to build query in PHP and retrieve data from MySQL database.
This would be easy if i had only one page and one query where i filter data, but i have more pages which pull data from everywhere around database.
What i have in my mind is to build front end HTML forms, with inputs corresponding to database fields, and then when i get form posted, to go via
if(some_field != '')
$q .= ' AND some_field = some_field_value';
problem is i have some fields which should be compared with LIKE and it only gets more complex introducing more fields and values..
I'm sure that there must be better approach to this problem.
I wonder, is there any good example of best practise to similar data filtering?