我想从特定用户中选择数据。当他登录网站时,他会看到与他有关的信息。
我正在使用INNER JOIN,我需要选择与他的登录名或身份证相关的数据。
我用来登录的任何帐户,我都可以访问注册的所有练习= /
在这种情况下,我正在使用ID。
查询有问题吗?
我没有从PHP得到任何错误。我在哪里可以放WHERE子句?
代码:
<?php
$login = $_SESSION['login'];
$consulta = mysqli_query($conexao,"SELECT exercicios.nome_exercicio AS nome_exc,
exercicios.repeticoes_exercicio AS rep_exc,
exercicios.serie_exercicio AS serie_exc
FROM exercicios
INNER JOIN usuarios ON usuarios.id_usuario = exercicios.id_usuario WHERE exercicios.id_usuario = '5'");
if(mysqli_num_rows($consulta)> 0){
echo "<div class='table-responsive'><table class='table table-responsive'>
<tr><td>Nome</td><td>Repetições</td><td>Série</td></tr>";
while ($exercicio = mysqli_fetch_assoc($consulta))
{
print"<tr>
<td>$exercicio[nome_exc]</td>
<td>$exercicio[rep_exc]</td>
<td>$exercicio[serie_exc]</td>
</tr>";
}
echo " </table></div>";
}
else {
echo "<h3>Seu instrutor ainda não cadastrou exercícios</h3>";
}
?>