<?php // Retrive template file $file = 'templates/page.html'; $tpl = file_get_contents($file); // Include files include 'includes/navbar.php'; include 'includes/summary.php'; // SQL query $sql_query = "SELECT song.title AS title, artist.name AS name, TIME_FORMAT(SEC_TO_TIME(song.duration),'%i:%s') AS duration\n FROM artist\n INNER JOIN song ON artist.id = song.artist_id\n ORDER BY artist.name, song.title ASC"; $result = $myconn->query($sql_query); // Check query if ($result === false) { $content .= $result->error; } elseif (mysqli_num_rows($result) == 0) { $content .= resultNotFound($lang['song_not_found']); } else { $cnt = 0; // Fetch associative array // $cnt variable is needed for unique html ids while ($row = $result->fetch_assoc()) { $cnt = $cnt + 1; $track = $row['title']; $artist = $row['name']; $duration = $row['duration']; $content .= songToHtml($track, $artist, $duration, $cnt); } } // Free result set $result->free(); // Set variables for placeholders
<?php // Retrive template file $file = 'templates/page.html'; $tpl = file_get_contents($file); // Include files include 'includes/navbar.php'; include 'includes/summary.php'; // SQL query $sql_query = "SELECT artist.name AS artist, count(song.artist_id) AS total\n FROM artist, song\n WHERE artist.id = song.artist_id\n GROUP BY song.artist_id\n ORDER BY artist.name ASC"; $result = $myconn->query($sql_query); // Check query if ($result === false) { $content .= $result->error; } elseif (mysqli_num_rows($result) == 0) { $content .= resultNotFound($lang['artist_not_found']); } else { $cnt = 0; // Fetch associative array // $cnt variable is needed for unique html ids while ($row = $result->fetch_assoc()) { $cnt = $cnt + 1; $artist = $row['artist']; $track_num = $row['total']; $content .= artistToHtml($artist, $track_num, $cnt); } } // Free result set $result->free(); // Set variables for placeholders $title = htmlspecialchars($lang['title_artists']);