Does anyone know what I have to do on this table so it doesn’t get crooked like that?

Asked

Viewed 41 times

0

inserir a descrição da imagem aqui

    foreach ($registro as $reg){

    echo "
<table class='centered' >
<thead>
<tr>
<th>Nome</th>
<th>Telefone</th>
<th>Email</th>
</tr>
</thead>";
    echo "<tbody>";
    echo "<tr>";
    echo "<td>".$reg['nome']."</td>";
    echo "<td>".$reg['telefone']."</td>";
    echo "<td>".$reg['email']."</td>";
    echo "</tr>";
    echo "</tbody>";
    echo "</table>";
}

1 answer

9


The problem is that you are creating several independent tables (look at the source of your page to better understand).

Take the table structure out of the loop, so it will have multiple rows in the same table:

<table class='centered' >
   <thead>
      <tr>
         <th>Nome</th>
         <th>Telefone</th>
         <th>Email</th>
      </tr>
   </thead>
   <tbody>
<?php
    foreach ($registro as $reg){
    echo "\t\t<tr>";
    echo "\t\t\t<td>".$reg['nome']."</td>";
    echo "\t\t\t<td>".$reg['telefone']."</td>";
    echo "\t\t\t<td>".$reg['email']."</td>";
    echo "\t\t</tr>";
}
?>
   </tbody>
</table>

Note that I added some \t us echo To indent, you don’t have to do this, and if you do, put as much as necessary to align right with the rest of HTML (to help you understand). The \t is the tab character, you can switch to blank spaces.

  • 1

    gave everything right here, thank you so much for your valuable help

Browser other questions tagged

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