Hi
I am building a product search engine using MySql and PHP (Jquery / AJAX).
As i am getting the search results i wondered is it possible to count the instances of a category?
For example:
If i search for "Dell Laptops" i get 400+ results back because it has lots of laptops and accessories.
What i am aiming for it to do is while looping through look at the categories and if its the first instanc eof it i want it to begin a count. until it has finished looping and then i can display it.
Results: 436 [ Laptops(127) - Accesories (244) - Components(65) ]
Im not even sure where to start here so any advice will be helpful 🙂
Here is the code im using to generate the search:
$id = str_replace(" ", "%", "$id");
$q = "SELECT * FROM products WHERE prod_name LIKE '%$id%' order by fee asc LIMIT 20";