X-Git-Url: https://git.sesse.net/?p=ccbs;a=blobdiff_plain;f=html%2Fplayer.pl;h=ce0e7137312fdc3027bdaf89f84b93eab892e4f4;hp=0fbde00f445ba54436b7951367fe931c746bc722;hb=34050d5b545b678e2af2980657d0f90a9d9de521;hpb=9cfb4ce473afa3ef82ccd1d3a1109b2cc0e69916 diff --git a/html/player.pl b/html/player.pl index 0fbde00..ce0e713 100755 --- a/html/player.pl +++ b/html/player.pl @@ -15,13 +15,14 @@ my $bestsongs = ccbs::db_fetch_all($dbh, 'SELECT song,title,score,tournament,tou # Fetch all scores and count a bit my $columns = 0; my @allsongs = (); -my $last_title = undef; +my $last_song = undef; -my $scores = ccbs::db_fetch_all($dbh, 'SELECT title,score FROM scores NATURAL JOIN songs WHERE player=? ORDER BY title,score DESC', $id); +my $scores = ccbs::db_fetch_all($dbh, 'SELECT song,title,score FROM scores NATURAL JOIN songs WHERE player=? ORDER BY title,score DESC', $id); for my $score (@$scores) { - my $title = $score->{'title'}; - if (!defined($last_title) || $title ne $last_title) { - push @allsongs, { title => $title, scores => [] }; + my $song = $score->{'song'}; + + if (!defined($last_song) || $song != $last_song) { + push @allsongs, { song => $song, title => $score->{'title'}, scores => [] }; } push @{$allsongs[$#allsongs]->{'scores'}}, $score->{'score'}; @@ -29,7 +30,7 @@ for my $score (@$scores) { my $this_columns = scalar @{$allsongs[$#allsongs]->{'scores'}}; $columns = $this_columns if ($this_columns > $columns); - $last_title = $title; + $last_song = $song; } ccbs::print_header();