This is my first post, I've been trying to solve a problem for some time now, but without success.
I have the CATEGORIES table and the PRODUCTS table
I need to display the following way:
CATEGORY 1
- Produto 1
- Produto 2
CATEGORY 2
- Produto 1
- Produto 2
I'm doing it this way (JUST AN EXAMPLE)
$var = SELECT * FROM categorias INNER JOIN produtos ON categorias.id = produtos.fk_idCategoria
But I'm lost when organizing when a category has more than 1 product, when I give print_r($var)
it displays the following:
CATEGORY 1
- Produto 1
CATEGORY 2
- Produto 1
CATEGORY 2
- Produto 2
Could someone give me a light?