0
I’m having trouble storing the values of ORDER BY
in php, I would like to store them in an array and show it on another page.
Database file with function:
function buscar_rank($conexao) {
$sqlBusca = 'SELECT * FROM usuario ORBER BY pontos;';
$resultado = mysqli_query($conexao, $sqlBusca);
$usuarios = array();
while ($rank = mysqli_fetch_assoc($resultado)) {
$usuarios[] = $rank;
}
return $usuarios;
}
file where you would like to store the results
<table>
<tr>
<?php $lista_rank = buscar_rank($conexao);
foreach($lista_rank as $rank) :
?>
<td><?php echo $rank['nome']; ?></td>
<td><?php echo $rank['pontos']; ?></td>
</tr>
<?php endforeach; ?>
What’s the problem? Returns some error?
– Roberto de Campos
Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs tcc back bank.php on line 69 the 69 line contains the while scope
– Gabriel Rabelo