How can CSS be used to format and display database query results in multiple columns in PHP?

To format and display database query results in multiple columns in PHP, you can use CSS to style the layout of the results. By using CSS properties like column-count or flexbox, you can divide the query results into multiple columns for a more organized display on the webpage.

<?php
// Perform database query
$query = "SELECT * FROM table_name";
$result = mysqli_query($connection, $query);

// Display query results in multiple columns
echo '<div style="column-count: 3;">';
while($row = mysqli_fetch_assoc($result)) {
    echo '<div>' . $row['column_name'] . '</div>';
}
echo '</div>';
?>