I am trying to display data from the table in two columns. The first column is filled, but the second remains empty, that is, just below the text is inserted, I can not understand what the problem is.

<?php $servername = "localhost"; $username = "mysql"; $password = "mysql"; $dbname = "wp"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT username, name FROM mailbox"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table border=3> <tr><th>e-mail</th><th>name</th></tr>"; while($row = $result->fetch_assoc()) { echo "<tr><td>" . " " . $row["username"]. "<br>"; echo "</tr></td>" . " " . $row["name"]. "<br>"; } } ?> 

enter image description here

  • name is in the mailbox table? - username
  • yes there is of course. - Alexey Grand
  • Here's how it all turns out for me, that is, it is not the name that climbs into the table column - Alexey Grand
  • Thank you very much! - Alexey Grand
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

It was derived but not in the table. replace

 echo "<tr><td>" . " " . $row["username"]. "<br>"; echo "</tr></td>" . " " . $row["name"]. "<br>"; 

on

 echo "<tr><td>" . " " . $row["username"]. "</td>"; echo "<td>" . " " . $row["name"]. "</td></tr>";