I have a page that displays the results dervied from a database query. I want to add a filter option so that users can filter by some of the results.
the results could include mixed data so I want to give the users the option to filter only a certain category. for instance, one of the columns displays the type of accommodation: all inclusive, half board, bed and breakfast etc so i want users to only see the all inclusive accommodation and can user the filter.
Can you please advise how to achive this in php? are there any tutorials or examples i can have a look at ?
thanks in advanc
just to clarify: i just want to filter on the results displayed. the first sql query displays the results on the page , but i need something else to filter the displayed results. I dont need another sql query as I am interested in filtering the results already displayed
Let MySQL do the filtering. When the user selects a category, add a WHERE condition to your query, so you’ll only extract the rows that have that category. No need to do any filtering in PHP
Do you have any examples or tutorials I can look at?
Yeah, if you are going back to the server you would use SQL. If you want to do the filtering client side (search within results) then JS is your option. You could use an Ajax call to have a whole new display returned to update the current page, but that will still involve having the SQL query get the rows you want.