When outputting data from a database in PHP, what are the best practices for aligning elements in a user-friendly manner?

When outputting data from a database in PHP, it is important to align elements in a user-friendly manner to enhance readability. One way to achieve this is by using HTML and CSS to style the output data in a visually appealing format. This can include using tables, divs, and proper spacing to organize and present the data in a structured way.

<?php
// Assume $data is an array of data retrieved from the database

echo '<table>';
foreach ($data as $row) {
    echo '<tr>';
    echo '<td>' . $row['column1'] . '</td>';
    echo '<td>' . $row['column2'] . '</td>';
    // Add more columns as needed
    echo '</tr>';
}
echo '</table>';
?>