This question already has an answer here:
I have a PHP/MYSQL based application in which there is a search area, when you search by dates then I show that a property/hotel is available between those dates. Also I have some other filters like area, facilities that Hotel has etc.
Now as of now everything working ok, but cutsomer now wants to show the number of records in bracket for each filter.
I tried it by adding multiple queries for each filter based on dynamic search user did, but that making my page performance slow. Because if I have 5 filters then I will run 5 queries.
I have seen such thing in magento, it counts the number of result that filter have as shown in picture below:
What will be the best method of doing this, I just need some logic and procedure which can be followed to resolve this.
Posting whole table structure is difficult, but I am positing shorter for of it, so you guys may have some idea and suggest some solution:
Tables are:
Properties - id, name
Factsheet_label - label_id, Name
Factsheet - id, label_id, prop_id, value (Yes, No)
I am showing all the filters from factsheet_label table and then I need to count the result of properties I have.
</div>