<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>