I only want to display 20 records per page, and I would like to have those page "markers" at the botton of the page for NEXT, PREVIOUS, and the links to the actual pages eg: 1, 2, 3 etc..
So far what I have is:
Expand|Select|Wrap|Line Numbers
- #!c:/Perl/bin/perl
- use strict;
- use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
- use DBI;
- use CGI qw(simple);
- #-------------------
- # Configure.........
- $| = 1;
- my $q = new CGI;
- print $q->header;
- my $database = 'complete';
- my $handle = '';
- my $password = '';
- my %attr = ( RaiseError => 0, PrintError => 0 );
- #-------------------
- # Application.......
- my $dbh = DBI->connect("DBI:mysql:$database:localhost:3306", $handle, $password, \%attr) || listErr( $DBI::errstr );
- my $sth = $dbh->prepare(qq{ SELECT * FROM lamtest });
- $sth->execute || listErr( $sth->errstr );
- my $news = $sth->fetchall_arrayref({});
- my $len = @{$news} / 20; # 20 records per page.
- if($len =~ /\./){ # If resultset is NOT evenly divisible
- $len =~ s/\d+\.*$//; # Chop off the decimal and everything else to the right.
- $len += 1; # add one to the quotient to allow for page with less then 20 rec
- }
- print $len; # this now equals how many slices there are. in $news array.
- # Also equals how many pages will be in the results.
- # Need to set up splices for each page...
- my $wts; # this will equal the x param, and/or "where to start splicing.
- # will need $lem number of these...
- my $num = 0;
- for(1..$len){
- $wts+$_ = $num;
- $num += 20;
- }
- my $point = $q->param('x');
- # these will be embedded in the page links..
- # will need more than one but just to give you the idea
- my @send = splice( @{$news},$num, 20);
- #--------------------------------
- # Subroutines.............
- sub listErr {
- my $e = shift;
- print "$e";
- }
I have also tried
Expand|Select|Wrap|Line Numbers
- "$wts"."$_" = $num;
Anyone know how to do this??
Or a better way to do ALL this??
Thank you!!
(please)