Problem:
You have a large form with many fields that can be left blank. If you are using the GET method for the form, you end up with a large url. If you then plan to limit the number of results per page, you need to keep reusing the huge and mostly empty url.
Solution:
This piece of code will strip out any empy value from a GET and update the $HTTP_GET_VAR array and $QUERY_STRING string which contains all this info.
If anyone knows a better way, or sees any problems that I have not encounter, post them below.
function remove_empties_from_get() {
global $HTTP_GET_VARS, $QUERY_STRING ;
while(list($key,$val) = each($HTTP_GET_VARS)) { if ($val == "")
{ unset($HTTP_GET_VARS[$key]) ; ;}
else { $string .= "$key=".
urlencode($val) . "&" ;} }
reset ($HTTP_GET_VARS) ;
$QUERY_STRING = $string ;
return $HTTP_GET_VARS ;
return $QUERY_STRING ;
}
Just thought this would be helpfull.
Andrew