How can CSS be integrated into PHP code to improve the styling and layout of data displayed from multiple tables?

When displaying data from multiple tables in PHP, integrating CSS can help improve the styling and layout of the information presented. By adding CSS styles to the HTML output generated by PHP, you can control the appearance of elements such as tables, text, and images. This can enhance the overall user experience and make the data more visually appealing.

<?php
// PHP code to fetch and display data from multiple tables
// Assume $data contains the fetched data

echo '<html>';
echo '<head>';
echo '<style>';
echo 'table {';
echo '  border-collapse: collapse;';
echo '  width: 100%;';
echo '}';
echo 'th, td {';
echo '  border: 1px solid black;';
echo '  padding: 8px;';
echo '}';
echo '</style>';
echo '</head>';
echo '<body>';

echo '<table>';
echo '<tr>';
echo '<th>Column 1</th>';
echo '<th>Column 2</th>';
echo '</tr>';

foreach($data as $row){
    echo '<tr>';
    echo '<td>' . $row['column1'] . '</td>';
    echo '<td>' . $row['column2'] . '</td>';
    echo '</tr>';
}

echo '</table>';

echo '</body>';
echo '</html>';
?>