Implement the years selection as select box
authorJoey Schulze <joey@infodrom.org>
Sun, 24 Aug 2008 13:47:14 +0000 (13:47 +0000)
committerJoey Schulze <joey@infodrom.org>
Sun, 24 Aug 2008 13:47:14 +0000 (13:47 +0000)
src/Infodrom/events/search.wml

index 4ea46b9..c3c2139 100644 (file)
 <form method=post action=find.php>
 
 <p><b>Keyword</b>: <input name=key size=30 maxsize=60>
-<br><b>Year</b>: <input name=year size=60 maxsize=10>
+<br><b>Year</b>: <select name=year><option value="">-- any year --<?
+
+  $query = "SELECT DISTINCT substr(start::text,0,5) AS year ".
+          "FROM events ORDER BY substr(start::text,0,5) DESC";
+
+  $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
+
+  $year = 0;
+  for ($i=0; $i < pg_NumRows ($sth); $i++) {
+    $row = pg_fetch_array ($sth, $i);
+    printf ("<option value=\"%s\">%s", $row['year'], $row['year']);
+  }
+
+?></select>
 <br><b>City</b>: <select name=city><option value="">-- any city --<?
 
   $query = "SELECT DISTINCT city FROM events ORDER BY city";