I am trying to implement a code to list information from 3 tables. I want to display only the data that has been registered by the user id = '20'
. This value '20' I'm getting a session variable and I want to put it in my list function but I'm not getting it.
follows:
$idSessao = $_SESSION['sessaoId'];
function listaProdutos($conexao){
$produtos = array();
$resultado = mysqli_query($conexao, "select p.*, c.nome as categoria_nome, u.id as id_usuario from produtos as p inner join categorias as c on c.id = p.categoria_id inner join usuarios as u on u.id = p.usuario_id where p.usuario_id = 20");
while ($produto = mysqli_fetch_assoc($resultado)){
array_push($produtos, $produto);
}
return $produtos;
}
Where is p.usuario_id = 20
would like to do this p.usuario_id = {$idSessao}
but it does not return anything.