I am making this code to capture the elements of a table in my database but when I run the foreach code I get the error and I do not know what to do
Data fetch function:
function listaUniformes($conexao) {
$uniformes = array();
$query = "select * from uniformes";
$resultado = mysqli_query($conexao, $query);
while($uniforme = mysqli_fetch_assoc($resultado)) {
array_push($uniformes, $uniforme);
}
return $uniforme;
}
Foreach:
<?php
listaUniformes($conexao);
foreach($uniformes as $uniforme) {
?>
<tr>
<?= $uniforme['nome']; ?>
</tr>
<?php } ?>
Error when entering page
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\warehouse\uniformes.php on line 21