mysqli - how can i group the ouput in php?

one text

Solution:

with mysl you will always get a flat array (so data will be repeated) so the idea would be to do nested foreach on the same array: the first will output the vendor, the second with an if on the vendor will echo the product type and the third will echo the products. But this is very unefficient.

I'd go for something like three different queries: find vendors, find product type and find products.

Third way is to manipulate your array to split it into different arrays for each vendor but this is yet less efficient compared to multiple queries IMHO

Source