Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Php Fetch Results into the table

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

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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();
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!