0
I have a table of produtos (id,id_categoria,nome,descricao)
and a table of imagens (id, FileName, id_produto)
.
I need to list product data and a product related table image by id.
$sql = $mysqli->query
("SELECT
produtos.nome,
imagens.FileName
FROM
produtos
INNER JOIN
imagens ON produtos.id_produto = imagens.id_produto
WHERE produtos.id_produto = '".$_GET['id']."'");
What error or difficulty you are encountering?
– Isac
it’s not working
– user90099
managed to understand my doubt?
– user90099
You are trying to make a query with php and mysql and it is not working ? which error appears?
– Isac
Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given
– user90099
The first part of Join doesn’t seem right to me. It should be
ON produtos.id = imagens.id_produto
. And I advise to test the query in phpMyAdmin or equivalent with an id of your choice to better understand the problem– Isac
changed but did not work: Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given
– user90099
Do
echo($mysqli->error);
to have a more concrete description of the error you have in the consultation– Isac
Maybe I didn’t know how to express myself, it’s the following: I’m listing products from a category by get. In this listing appears the products all straight, but is not appearing the image, which is in a third table. So I have 3 tables: - categories - products - pictures
– user90099
So far so good: $sql = $mysqli->query("SELECT * FROM products WHERE id_categoria = '". $_GET['id']."'");
– user90099