Index: trunk/ippMonitor/raw/ipp.php
===================================================================
--- trunk/ippMonitor/raw/ipp.php	(revision 15954)
+++ trunk/ippMonitor/raw/ipp.php	(revision 18143)
@@ -364,6 +364,13 @@
 }
 
-function check_restrict ($key, $where) {
+function check_restrict ($key, $where, $mode) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($mode == 'min') {
+    $htmlkey = $htmlkey . "_min";
+  }
+  if ($mode == 'max') {
+    $htmlkey = $htmlkey . "_max";
+  }
+
   if ($_SERVER[REQUEST_METHOD] == 'GET') { 
     $value = $_GET[$htmlkey]; 
@@ -371,11 +378,24 @@
     $value = $_POST[$htmlkey];
   }
-  if ($value != "") {
-    if ($where) {
-      $where = $where . " AND $key = '$value'";
-    } else {
-      $where = "WHERE $key = '$value'";
-    }
-  }
+  if ($value == "") { return $where; }
+  if ($where) { 
+    $where = $where . " AND"; 
+  } else {
+    $where = "WHERE";
+  }
+
+  if ($mode == 'string') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key like '$value'";
+  } 
+  if ($mode == 'min') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key >= '$value'";
+  } 
+  if ($mode == 'max') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key <= '$value'";
+  } 
+
   return $where;
 }
@@ -394,5 +414,6 @@
 }
 
-function button_restrict ($key, $line) {
+// if we have a restriction for a string-valued field, supply it to outgoing links
+function button_restrict_string ($key, $line) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
   if ($_SERVER[REQUEST_METHOD] == 'GET') { 
@@ -411,4 +432,42 @@
 }
 
+// for numerical fields, test for both 'min' and 'max' values
+function button_restrict_min ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  $htmlkey = $htmlkey . '_min';
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
+// for numerical fields, test for both 'min' and 'max' values
+function button_restrict_max ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  $htmlkey = $htmlkey . '_max';
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
 function write_table_header ($class, $name, $value, $buttonLink, $ID, $file) {
 
@@ -420,6 +479,14 @@
 }
 
-function write_query_row ($key, $width) {
+// there are two query rows: for strings, only the first is set; for numbers, the first = min, the second = max
+// mode == string, min, max
+function write_query_row ($key, $width, $mode) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($mode == 'min') {
+    $htmlkey = $htmlkey . "_min";
+  }
+  if ($mode == 'max') {
+    $htmlkey = $htmlkey . "_max";
+  }
   if ($_SERVER[REQUEST_METHOD] == 'GET') { 
     $value = $_GET[$htmlkey]; 
@@ -427,8 +494,9 @@
     $value = $_POST[$htmlkey];
   }
+  // XXX need to modify $key (should it be htmlkey here?)
   if ($value != "") { 
-    echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\" value=\"$value\"> </td>\n";
-  } else {
-    echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\"> </td>\n";
+    echo "<td class=\"list\"> <input type=\"text\" name=\"$htmlkey\" size=\"$width\" value=\"$value\"> </td>\n";
+  } else {
+    echo "<td class=\"list\"> <input type=\"text\" name=\"$htmlkey\" size=\"$width\"> </td>\n";
   }
 }
