What are some best practices for formatting and displaying query results in PHP?

When displaying query results in PHP, it is important to format the data in a clear and organized manner for better readability. One best practice is to use HTML tables to display the results in rows and columns. This makes it easier for users to scan and understand the data.

// Assuming $results is an array of query results
echo "<table>";
echo "<tr><th>ID</th><th>Name</th><th>Email</th></tr>";
foreach ($results as $row) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['email'] . "</td>";
    echo "</tr>";
}
echo "</table>";