From f8ae360851686865a550e308115310c650996ef4 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 25 Mar 2012 17:15:24 +0200 Subject: [PATCH] Factor out subdivision-fetching code. --- www/index.pl | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) 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"; -- 2.39.2