]> git.sesse.net Git - wloh/commitdiff
Lock season to newest.
authorSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 17:35:55 +0000 (18:35 +0100)
committerSteinar H. Gunderson <Steinar H. Gunderson sesse@debian.org>
Sat, 17 Mar 2012 17:35:55 +0000 (18:35 +0100)
www/index.pl

index a4c16fd949c74e63e3e2afeb5e12295c2901f12d..7cedd6fe2e81f714f1a7762d51ef501131c1127b 100755 (executable)
@@ -138,7 +138,7 @@ while (my $ref = $q->fetchrow_hashref) {
 }
 $match_stddev = $parms{-2} * sqrt(2.0);
 
-my $season = $cgi->param('sesong') // -1;
+my $season;
 my $division = $cgi->param('divisjon') // -1;
 my $subdivision = $cgi->param('avdeling') // -1;
 
@@ -179,33 +179,17 @@ td {
     <p>Spillerne er sortert etter nick.</p>
 
     <form method="get" action="/">
-      <p>Sesong:
-        <select name="sesong">
 EOF
 
-$q = $dbh->prepare('SELECT DISTINCT(sesong) FROM fotballserier ORDER BY sesong');
+$q = $dbh->prepare('SELECT MAX(sesong) AS max_sesong FROM fotballserier');
 $q->execute;
-my $max_season;
-my @seasons = ();
+my $season;
 while (my $ref = $q->fetchrow_hashref) {
-       push @seasons, $ref->{'sesong'};
-       $max_season = $ref->{'sesong'};
-}
-
-my $found_season = 0;
-for my $s (@seasons) {
-       if ($s == $season || (!$found_season && $s == $max_season)) {
-               print "        <option value=\"$s\" selected=\"selected\">$s</option>\n";
-               $season = $s;
-               $found_season = 1;
-       } else {
-               print "        <option value=\"$s\">$s</option>\n";
-       }
+       $season = $ref->{'max_sesong'};
 }
 
 print <<"EOF";
-        </select>
-        Divisjon:
+     <p>Divisjon:
         <select name="divisjon">
 EOF