Below are my codes, However, I didn't get a table as I expect. Rather than the first row only seeming to be ok, Other Rows are not coming in the table. Please refer to the photo.
$Sql = "SELECT Registration_Number,Name FROM vta";
$Result = $conn->Query($Sql);
if ($Result -> num_rows> 0) {
echo "<table border=2>
<tr><th>Registration_Number</th>
<th>Name</th></tr>";
while ($Row = $Result->fetch_assoc()) {
// $Rm=$Row['Registration_Number'];
// $Nm = $Row['Name'];
echo "<tr><td>$Row[Registration_Number]</td><td>$Row[Name]</td></tr></table>";
}
}
$conn->Close();
enter image description here
You have to move the closing </table> outside the loop.
$Sql = "SELECT Registration_Number,Name FROM vta";
$Result = $conn->Query($Sql);
if($Result->num_rows > 0) {
echo "<table border=2>
<tr><th>Registration_Number</th>
<th>Name</th></tr>";
while ($Row = $Result->fetch_assoc()){
echo "<tr><td>$Row['Registration_Number']</td><td>$Row['Name']</td></tr>";
}
echo '</table>';
}
$conn->Close();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With