I'm trying to get my database grouped by release year of the movie. So that when, for example, 2016 is retrieved from the database that it will show every movie from 2016 but after 2016 i want it to show 2015 aswell etc. Right now I have it that it will show every movie from 2016 but 2016 is repeated every time see this image But what I want to have is that 2016 is only listed once and a list will follow with all titles that are associated to that year and when that's over I want to show everything by 2015 etc. I tried to use group by code but then I end up with only one movie per yearexample2.
So what I want to accomplish is something like this: 2016: Film 1 Film 2 Film 3 etc. 2015: Film 1 Film 2 etc. etc.
Does anyone know how to fix this?
<?php
include("../header.php");
$servernaam = "localhost";
$username = "root";
$password = "";
$dbnaam = "datainfo1_filmsdb";
$connectie = mysqli_connect($servernaam, $username, $password, $dbnaam);
if(mysqli_connect_errno() > 0) {
echo "Problemen met het verbinden met de database.";
die();
}
$sql = "SELECT release_year, title FROM films ORDER BY release_year DESC";
$result = mysqli_query($connectie, $sql);
$aantalRijen = mysqli_num_rows($result);
echo "<strong><i>Films per year</i></strong>";
echo "<BR />";
if($aantalRijen > 0) {
while($rij = mysqli_fetch_assoc($result)) {
echo "<div>";
echo "<BR />";
echo "<strong>Jaar Gepubliceerd: </strong>";
echo $rij['release_year'];
echo "<BR />";
echo "<strong>Titel: </strong>";
echo $rij['title'];
echo "<BR />";
echo "</div>";
}
}
mysqli_close($connectie);
include("../footer.php");
?>