Here is a quick sample of code I have used.  I will comment for you later if
you like but have to run now.

my $query = "SELECT STUFF HERE";

 # HTML::Pager callback subroutine
  my $get_data = sub{
    my ($offset,$rows) = @_;

      $query .= " limit $offset,$rows";
    my $sth = $dbh->prepare($query);
       $sth->execute() || die $sth->errstr;

    return $sth->fetchall_arrayref({});

  };#end callback sub


  my $pager = HTML::Pager->new(
                                query=>$self->query(),
                                get_data_callback=>$get_data,
                                rows=>$rows,
                                page_size=>$self->param('PAGE_SIZE') || 10,
                                template=>$template,
                                NEXT_LINK_TEXT=>'Next',
                                PREV_LINK_TEXT=>'Prev',
                                );


----- Original Message -----
From: "Roy Rubin" <[EMAIL PROTECTED]>
To: "Cgiapp" <[EMAIL PROTECTED]>
Sent: Thursday, May 02, 2002 6:28 PM
Subject: [cgiapp] CGI::Application and HTML::Pager


> Hello,
>
> I am trying to provide some paginated search results and got stock with
> compile problems. Can anyone provide an example of using HTML::Pager and
> CGI:Application.
>
> Got an error: syntax error at GLX.pm line 69, near "sub d_search " syntax
> error at GLX.pm line 90, near "}" Compilation failed in require at
> C:\projects\GLX\cgi-bin\engine.pl line 14. BEGIN failed--compilation
aborted
> at C:\projects\GLX\cgi-bin\engine.pl line 14.
>
> Thanks.
>
> Roy
> http://www.irubin.com
>
>
>
> <snippet - using just the default samples provided will not compile>
>
>   my $get_data_sub = sub {
>      my ($offset, $rows) = @_;
>      my @return_array;
>      for (my $x = 0; $x < $rows; $x++) {
>         push(@return_array, [ $data[$offset + $x]{name},
>                               $data[$offset + $x]{age}
>                             ]
>             );
>      }
>      return \@return_array;
>   }
>
>
>
> sub d_search {
> my $self = shift;
> my $q = $self->query();
> my $output;
> my $config = $self->param('config');
>
> %uservalues = $q->Vars;
> my $thtml = $self->load_tmpl($config->get_base_template_path .
> $config->get_search_results, die_on_bad_params => 0);
>
>
>
> $pager = HTML::Pager->new(
> query => $q,
> get_data_callback => whatever(),
> rows => $rv,
> page_size => 15,
> template => $thtml
> );
> }
>
>
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to