From: Steinar H. Gunderson Date: Sun, 25 Mar 2012 15:15:24 +0000 (+0200) Subject: Factor out subdivision-fetching code. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f8ae360851686865a550e308115310c650996ef4;p=wloh Factor out subdivision-fetching code. --- diff --git a/www/index.pl b/www/index.pl index c63ae09..ef2e15e 100755 --- a/www/index.pl +++ b/www/index.pl @@ -62,6 +62,21 @@ sub get_divisions { return @divisions; } +sub get_subdivisions { + my ($dbh, $season, $division) = @_; + + my @subdivisions = (); + + my $q = $dbh->prepare('SELECT DISTINCT(avdeling) FROM fotballserier WHERE sesong=? AND divisjon=? ORDER BY avdeling'); + $q->execute($season, $division); + + while (my $ref = $q->fetchrow_hashref) { + push @subdivisions, $ref->{'avdeling'}; + } + + return @subdivisions; +} + sub make_table { my ($lowest_division, $used_ratings, $used_cov) = @_; @@ -229,23 +244,17 @@ print <<"EOF";