List database query in two columns for the user. - PHP

0

I'm developing a simple system to go practicing my knowledge and I'm in a moment that I want to perform a query to the database and to return to the screen in two columns, the query part is ok, but it lists all the data one underneath the another and I do not want it to be this way, someone would know how to help me?

I want it to look something like this:

....

andthecodelookslikethis:

<?phpinclude"conexao.php";

    $sql = "SELECT * FROM usuarios";
    $query = mysql_query($sql);
    $row = mysql_num_rows($query);
    $i = 0;

    while($linha = mysql_fetch_array($query)){
        $id = $linha['id'];
        $nome = $linha['nome'];
        $email = $linha['email'];

    }
?>
    
asked by anonymous 14.10.2018 / 22:27

1 answer

0

For this you should use HTML and follow a structure similar to this by simply making the HTML changes you want:

echo "<table>";
while($linha = mysql_fetch_array($query)){
 echo "<tr><td>id:</td>";
 echo "<td>".$linha["id"]."</td>";
 echo "<tr><td>nome:</td>";
 echo "<td>".$linha["nome"]."</td>";
 echo "<tr><td>email:</td>";
 echo "<td>".$linha["email"]."</td></tr>";
}
echo "</table>";

And I recommend you get a lookup before opening new questions since there was already one very similar to yours right here on the stack: #

    

15.10.2018 / 13:13