2
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 ways:
CATEGORY 1
- Produto 1
- Produto 2
CATEGORY 2
- Produto 1
- Produto 2
I am doing it as follows (JUST AN EXAMPLE)
$var = SELECT * FROM categorias INNER JOIN produtos ON categorias.id = produtos.fk_idCategoria
But I am lost in organizing when a category has more than 1 product, when I give print_r($var)
displays the following:
CATEGORY 1
- Produto 1
CATEGORY 2
- Produto 1
CATEGORY 2
- Produto 2
Someone could give me a light ?
Hello, first of all thank you. I forgot to mention, I need to access other product columns, for example PRODUCT 1, I need to access the price, the description etc. In this way that you mentioned, I can only return a column that would be the [product], correct ?
– Jonas
can yes, I edited the answer
– arllondias
Thanks arrllondias, solved my problem.
– Jonas
You’re welcome @Jonas.
– arllondias