Good afternoon all,
I'm pretty new to PHP, but have been picking it up slowly over the last few months. However, today i've reached a very large hurdle...
I have a database of products, the database also contains 'Brands'.
E.g.
Name Brand
Shirt Armani
TShirt Prada
Jeans Prada
Shirt Armani
TShirt Prada
Jeans Armani
etc...
I have a query to pull-out distinct Brands, and sort them by the number of products each Brand has.
This works OK for me.
I have an array where I've specified an ordering preference for displaying these Brands on the page...
$brand_order = array("armani" => 1, "prada" => 2, "g-star" => 3);
I want to limit the number of brands I show on the page to 15, however...
I can't do this by simply adding a limit to the first query, because we want to be a bit picky of it comes down to a 'tie-breaker' for brands that show the same number of products...
E.g.
The database pulls out 20 brands
The top Brands 1 - 13 are OK, and contain quite high product quantities, but say Brand number 14, 15, 16 and 17 each return 10 products- then I want to check against the $brand_order array and display them in the order shown.
at the same time, I don't want the number of brands shown to exceed 15.
Make sense? I'm not even sure I understand it any more, but i'm sure there's someone out there who could help me!!
In short, I want to:
Thanks in advance,
Rachael