My scenario is as follows: I have a function called UserSearch ()
function buscaUsuario($conexao)
{
$retornar = array();
$query = mysqli_query($conexao, "SELECT user_name FROM usuarios");
while($result = mysqli_fetch_assoc($query))
{
$retornar[] = $result;
}
return $retornar;
}
I also have a file named demand-user.php and there is the following code snippet:
<?php
$all = buscaUsuario($conexao);
$ab = sizeof($all);
$i = 0;
for ($i = 0; $i < $ab; $i++)
{
?>
<tr>
<td><?=implode($all[$i])?></td>
</tr> <?php
}
?>
I am returning the query in an array to be displayed in a table. Previously I tried to do it in a more succinct way (at least for me) but it would enter an infinite loop and crash the browser. And this other way was as follows: in the userSearch () function I created a variable that received mysqli_fetch_array () and returned that variable. So in search-user.php I would call this function and play within a while so the table would be populated until there was no more row inside the array ... And this (as I said up there) made the browser crash , I decided to do it that way that I showed them. However, if I add another field in the select and I command to print within that, the cells of each row in the table are not populated, just the first row, thus: userNameCompleteSequenceNode
I wanted to understand what I'm doing wrong and what would be the best way to do what I'm trying to do ... Thank you folks!