Index: trunk/www/db_po/get_keys.php
===================================================================
--- trunk/www/db_po/get_keys.php	(revision 11353)
+++ trunk/www/db_po/get_keys.php	(revision 11505)
@@ -9,4 +9,10 @@
         return;
     }
+    if (empty($_GET["fKey"]))
+        $_GET["fKey"]="";
+    if (empty($_GET["fSelectSize"]))
+        $_GET["fSelectSize"]="10";
+    if (empty($_GET["fMode"]))
+        $_GET["fMode"]="view";
 
     include("db.php");
@@ -19,18 +25,36 @@
     mysql_select_db($db);
 
-    $query0="SELECT fKey from ProgramOption ";
+    $query1 = "SELECT Max(fCounter) FROM History";
+    $result1=mysql_query($query1, $db_id);
+    $row1 = mysql_fetch_row($result1);
+    $maxcounter=$row1[0];
+    mysql_free_result($result1);
+
+    $query0="SELECT Concat(fKey1, fKey2) as ourkeys from ProgramOption ";
+    $query0.="WHERE fCounter=".$maxcounter." ";
     if ($_GET["fProgram"]!="all")
-        $query0.="WHERE fProgram='".$_GET["fProgram"]."' ";
-    $query0.="GROUP BY fKey";
+        $query0.="AND fProgram='".$_GET["fProgram"]."' ";
+    $query0.="GROUP BY ourkeys";
 
     $result0=mysql_query($query0, $db_id);
 
-    printf("<td>Please select a key:</td>\n");
-    printf("<td><select name='key' size='1' onchange=\"get_values('%s',this.value)\"class='Width'>\n", $_GET["fProgram"]);
-    printf("<option value='empty'> ---select key--- </option>\n");
-    printf("<option value='newkey'> add new key </option>\n");
+    if (strcmp($_GET["fMode"], "edit")==0)
+        printf("select key: <br>\n");
+    else
+        printf("select key: \n");
+    printf("<select style='width:200px' id='key' size='%s' onchange=\"get_values(1,'%s',this.value,'%s')\"class='Width'>\n",
+           $_GET["fSelectSize"], $_GET["fProgram"], $_GET["fMode"]);
+    if (!empty($_GET["fKey"]) && strcmp("all", $_GET["fKey"])==0)
+        printf("<option value='all' selected> --- all keys --- </option>\n");
+    else
+        printf("<option value='all'> --- all keys --- </option>\n");
     while ($row0 = mysql_fetch_row($result0))
-        printf("<option value='%s'>%s </option>\n", $row0[0], $row0[0]);
-    printf("</select>\n</td>\n");
+        if (!empty($_GET["fKey"]) && strcmp($row0[0], $_GET["fKey"])==0)
+            printf("<option value='%s' selected>%s </option>\n", $row0[0], $row0[0]);
+        else
+            printf("<option value='%s'>%s </option>\n", $row0[0], $row0[0]);
+    printf("</select>\n<br>\n");
+    if (strcmp($_GET["fMode"], "edit")==0)
+        printf("<button onClick='addRow(2,\"%s\",\"\",\"\",\"\",\"\");' id='addrowkey' style='display:inline'>Add Key</button>\n", $_GET["fProgram"]);
     mysql_free_result($result0);
 
