Fetch year from database
authorJoey Schulze <joey@infodrom.org>
Thu, 26 Jun 2008 12:23:40 +0000 (12:23 +0000)
committerJoey Schulze <joey@infodrom.org>
Thu, 26 Jun 2008 12:23:40 +0000 (12:23 +0000)
src/InfoCon/account/query.wml

index a22a978..bc61e7d 100644 (file)
@@ -72,7 +72,17 @@ input.submit:hover {
 ?>
 
 <label for=year>Jahr</label>
-<input id=year name=year size=10 maxlength=4>
+<select id=year name=year>
+<option>
+<?
+  $query = "SELECT DISTINCT substr(datum,0,5) AS year FROM $table ORDER BY year DESC";
+  $sth = pg_exec ($dbh, $query);
+
+  for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
+    $row = pg_fetch_array ($sth, $nr);
+    printf ("<option value=\"%s\">%s", $row['year'], $row['year']);
+  }
+?></select>
 
 <? if (!isset($_GET["cur"]) || $_GET["cur"] != "dm") { ?>