Logo Luan Morina
Display records in columns
A Whiter Shade of Pale
Procol Harum (1967)

A Woman in Love
Barbra Streisand (1980)

All That She Wants
Ace of Base (1993)

Angie
The Rolling Stones (1973)

Another Day in Paradise
Phil Collins (1989)

Baby One More Time
Britney Spears (1999)

Barbie Girl
Aqua (1997)

Believe
Cher (1998)

Bette Davis Eyes
Kim Carnes (1981)

Source Code

<div class="container">
<div class="row justify-content-between">
<?php
$conn = new mysqli ("server-name", "user-name", "user-password", "database-name");
mysqli_set_charset ($conn, "utf8");
if ($conn -> connect_error) {
die ("Error: " . $conn->connect_error);
}
$sql = "SELECT * FROM top_100_songs_eu ORDER BY song ASC LIMIT 0, 9";
$result = $conn -> query($sql);
if ($result -> num_rows > 0) {

while ($row = $result -> fetch_assoc()) { 
$row_song_title[] = '<strong>' . $row["song"] . '</strong><br />' . $row["artist"] . ' (' . $row["year"] . ')<br /><br />'; 
$songs_list = array_chunk($row_song_title, ceil(count($row_song_title) / 3));
}

foreach ($songs_list as $songs_column) {
echo '<div class="col-md-4">';
foreach ($songs_column as $song_output) { 
echo $song_output;
}
echo "</div>";
} 
} 
else {
echo "No records found";
}
$conn -> close();
?>
</div>
</div>
   Display MySQL records in columns