# 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'};
my $this_columns = scalar @{$allsongs[$#allsongs]->{'scores'}};
$columns = $this_columns if ($this_columns > $columns);
- $last_title = $title;
+ $last_song = $song;
}
ccbs::print_header();
-ccbs::process_template('player.tmpl', $player->{'title'}, {
+ccbs::process_template('player.tmpl', $player->{'nick'}, {
player => $player,
bestsongs => $bestsongs,
allsongs => \@allsongs,