How do I put a filter expression in the URL using Perl?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spyka
    New Member
    • Sep 2010
    • 10

    How do I put a filter expression in the URL using Perl?

    I have issue regarding paging using filter expression. Here's the piece of code for filtering:

    Code:
    if ( $q->param("Filter") )
                {
                $Id=$q->param('User_Id');
                $Name=$q->param('User_Name');
    
               if ($Id ne "" )
                    {
                  $filterexpression= $filterexpression." UserId like '" .$Id. "%' and " ;
                     }
                if ($Name ne "" )
                  {
                $filterexpression= $filterexpression." UserName like '" .$Name. "%' and " ;
                   }
                  }
                $filterexpression= $filterexpression. " UserId > 0"
    and here's chunk of the paging code:

    Code:
    print qq[<td><a href="UsersList.cgi?
             pageNum=$pageN&limit=$limit&SortBy=$SortBy&SortOrder=$SortOrder">&lt;</a></td>];
    The issue is I want to put the filter expression in this HREF after the sort order variable,
    so that after filtering when I go for paging then only those records confined to the filter expression should be shown.

    I tried to merge this way:

    Code:
    print qq[<td><a href="UsersList.cgi?
                    pageNum=$pageN&limit=$limit&SortBy=$SortBy&SortOrder=$SortOrder
                     &Filter=$filterexpression">&lt;</a></td>];
    but in URL I got to see something like this:

    Code:
    http://localhost/cgi-bin/UsersList.cgi?
                      pageNum=1&limit=3&SortBy=UserId&SortOrder=Asc&filter=%20%20UserId%20like%
                      20'1%'%20and%20%20UserId%20>%200
    Later I tried to put the `$Id` value in a varible like:

    Code:
    $string =~ m/^$Id/;
    but when I tried printing this variable I got nothing.PLEASE HELP ME OUT FIND THE SOLUTION,and apart from using CPAN is their any other solution because i am having 0% knowledge about it.
    Last edited by numberwhun; Oct 8 '10, 02:14 AM. Reason: Please use Code Tags!!
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Please be sure and use code tags around any code that you put into the forums.

    Comment

    Working...