What are the best practices for handling table widths in PHP?

When handling table widths in PHP, it is important to set the width of the table and its columns appropriately to ensure a well-designed layout. One common approach is to use CSS to set the width of the table and its columns. This allows for more flexibility and control over the table layout compared to setting the width directly in PHP.

echo '<table style="width: 100%;">';
echo '<tr>';
echo '<th style="width: 30%;">Column 1</th>';
echo '<th style="width: 70%;">Column 2</th>';
echo '</tr>';
echo '<tr>';
echo '<td style="width: 30%;">Data 1</td>';
echo '<td style="width: 70%;">Data 2</td>';
echo '</tr>';
echo '</table>';