I am making a list of users and the data does not appear on the page. I waited for the user's name, his type, and the number of posts and replies he sent to the system to appear. There is another problem. Three users are registered, but only one appears. Below is the code:
<?php
$conecta = new MySQLi("localhost","root","","forum-ti-1");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial- scale=1">
<title></title>
<link rel="stylesheet" href="css/style.css">
<script src="js/script.js"></script>
</head>
<body>
<?php
include('templates/header.html.php');
?>
<div class="head_topics" style="top: 330px; left: 210px;">
<h2>Usuários</h2>
</div>
<table class="t_subtopics" style=" top: 370px; left:210px;">
<?php
$usuario = "SELECT usuario.nome, situacao_usuario.descricao, COUNT(discussao.titulo) As posts, COUNT(resposta.conteudo) AS respostas
FROM usuario, situacao_usuario, discussao, resposta
WHERE usuario.id_situacao = situacao_usuario.id AND usuario.id = discussao.id_usuario AND usuario.id = resposta.id_usuario";
$lista = $conecta->query($usuario);
while($rs = $lista->fetch_array()){
?>
<tr>
<td style="width: 200px;">
<div class="discussion_photo">
<img src="images/profile-photo.jpg" style="height: 80px; width: 100px; display: block;"/>
</div>
</td>
<td style="width: 500px;">
<ul>
<li><h3 style="font-size: 20px;"><? echo $rs['usuario.nome']; ?></h3></li>
<li id="discussion_type_user" style="width: 80px; padding: 5px;"><? echo $rs['situacao_usuario.descricao']; ?></li>
</ul>
</td>
<td style="width: 200px;">
<ul>
<li><? echo $rs['posts']; ?> tópicos</li>
<li><? echo $rs['respostas']; ?> respostas</li>
</ul>
</td>
</tr>
<?php
}
?>
</table>
<?php
include('templates/footer.html.php');
?>
</body>
The figure below shows the result:
Iusedthequery:
"SELECT usuario.nome, situacao_usuario.descricao, COUNT(discussao.titulo) As posts, COUNT(resposta.conteudo) AS respostas
FROM usuario, situacao_usuario, discussao, resposta
WHERE usuario.id_situacao = situacao_usuario.id
AND usuario.id = discussao.id_usuario
AND usuario.id = resposta.id_usuario
GROUP BY usuario.id"
but did not return any data:
Issue
Thequeryontheserverworked,butitdidnotappearonthepage:
(Edition)