What is the best practice for displaying database records side by side in PHP?

When displaying database records side by side in PHP, one common approach is to use HTML and CSS to create a table-like layout. This can be achieved by fetching the records from the database, looping through them, and displaying each record in a separate table cell. By using CSS to style the table cells, you can control the layout and appearance of the records on the page.

<?php
// Connect to the database
$pdo = new PDO('mysql:host=localhost;dbname=database_name', 'username', 'password');

// Fetch records from the database
$stmt = $pdo->query('SELECT * FROM table_name');
$records = $stmt->fetchAll();

// Display records side by side in a table-like layout
echo '<table>';
echo '<tr>';
foreach ($records as $record) {
    echo '<td>';
    echo $record['column1'] . '<br>';
    echo $record['column2'] . '<br>';
    echo $record['column3'];
    echo '</td>';
}
echo '</tr>';
echo '</table>';
?>