-2
I’m developing a ranking with php
and sql
, I can list the data correctly. However, I need to make sure that no repeated records appear.
My code:
<?php
include_once('conexao.php');
$rank = "SELECT * FROM ranking ORDER BY pontuacao DESC LIMIT 0, 6";
$query = mysqli_query($mysqli, $rank);
$i = 0;
if(($query) AND ($query->num_rows != 0)){
while($row = mysqli_fetch_assoc($query)){
$id_usuario = $row['id_usuario'];
$pontos = $row['pontuacao'];
}
}
?>
<html>
<body>
<div style="background: lightgray;width: 120px;height: 40px; margin-bottom: 20px; padding: 30px;">
<h5><?php echo "id_usuario: ".$id_usuario." "."<br>pontos: ".$pontos; ?></h5>
</div>
</body>
</html>
<?php
} else {
echo "nem um registro encontrado!";
}
edit and improve your question. Put your code better tbm
– user148170