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

Asked

Viewed 217 times

0

I am developing a simple system to practice my knowledge and I am at a time I want to perform a query to the database and resume on the screen in two columns, the part of the query is ok, but lists all the data under each other and I don’t want it to be like this, someone would know how to help me?

I want it to be more or less like this:

.... inserir a descrição da imagem aqui

and the code is like this:

<?php
    include "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'];

    }
?>

1 answer

0

To do this you must use HTML and follow a structure similar to this just by 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 that you do a research before opening new questions because there was already one very similar to yours right here in the stack : To display the result of a query in a PHP html page?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.