Are there any best practices or guidelines for formatting and displaying MySQL query results in a table using PHP?

When displaying MySQL query results in a table using PHP, it is important to follow best practices for formatting and displaying data in a clear and organized manner. One common approach is to use HTML table tags to structure the data in rows and columns. You can also use CSS to style the table for better visual presentation.

<?php
// Assume $result is the MySQL query result
echo "<table>";
echo "<tr><th>ID</th><th>Name</th><th>Email</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['email'] . "</td>";
    echo "</tr>";
}
echo "</table>";
?>