diff --git a/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc b/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc
index d399f19..600e869 100644
--- a/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc
+++ b/uc_views_attribute/views/uc_views_attribute_handler_filter_attr.inc
@@ -68,10 +68,12 @@ class uc_views_attribute_handler_filter_attr extends views_handler_filter_in_ope
     }
     foreach ($this->value as &$value) {
     	if($this->options['type'] == 'textfield') {
-    	   $optval = $value;
+          $optval = $value;
+          $optnum = db_result(db_query('SELECT oid FROM {uc_attribute_options} WHERE name = %s', $value));  
     	}
     	else {
-    	 $optval = db_result(db_query('SELECT name FROM {uc_attribute_options} WHERE oid = %d', $value));
+          $optnum = $value;
+          $optval = db_result(db_query('SELECT name FROM {uc_attribute_options} WHERE oid = %d', $value));
     	}
     	if(!$optval) {
     	  //If we let the query get added, only products with the attribute enabled & with the value of that attribute empty
@@ -83,7 +85,7 @@ class uc_views_attribute_handler_filter_attr extends views_handler_filter_in_ope
     	  //products. If checked, a blank value at least filters out products that dont have this attribute available.
     	  continue;
     	}
-    	$var = array($key => array(0 => $optval));
+        $var = array($key => array($optnum => $optval));
     	$servar = serialize($var);
     	$l = strpos($servar,'{')+1;
     	$r = strpos($servar,'}')-$l;
@@ -93,4 +95,3 @@ class uc_views_attribute_handler_filter_attr extends views_handler_filter_in_ope
     }
   }
 }
-
