[Solved] How to loop php sql output into a table? [duplicate]


This is how you have to add the data into a table.

if (mysqli_num_rows($result) > 0) {
    echo "<table>";
    echo "<tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Appointment Time</th>
        </tr>";
    while($row = mysqli_fetch_assoc($result)) {
        echo "<tr>
                <td>{$row['FirstName']}</td>
                <td>{$row['LastName']}</td>
                <td>{$row['AppTime']}</td>
            </tr>";
    }
    echo "</table>";
} else {
    echo "No results, please try again";
}

If the issue is related to your query speed, please consider adding pagination. Or try to Index your DB table.

solved How to loop php sql output into a table? [duplicate]