in reply to Re^13: Need help with pagination
in thread Need help with pagination
Now I have the following output : <-1-> <-2-> <-3-> <-4-> <-5-> <-6-> <-7-> <-8-> <-9-> <-"Next"-> Thx for kind help.#!c:/xampp/perl/bin/perl.exe use warnings; use CGI; use Time::HiRes qw(gettimeofday); my $query = CGI->new; my $dir = "C:/Users/41786/OneDrive/Documents/recordz1/"; print $query->header; test(); sub test { my $counter = 1000; #Should be get from db; my $string = ""; my $first_page = 0; my $min_index = $query->param("min_index"); if ($min_index = '') { $min_index = 0; } open (FILE, "<$dir/test2.html") or die "cannot open file $dir/test +2.html"; my $content = ""; my $max_index = $query->param("max_index"); if ($max_index = '') { $max_index = 40; }else { $max_index = round ($counter / 40, 1);#Number of objects displ +ayed per page. } my $last_page = $nb_page - 1; my $n2 = 0; my $count_per_page = 10; my $index_page = 0; for my $index (0..$max_index) { $next_page = $min_index + 40; if ($index < $count_per_page) { if (($index % $count_per_page) > 0) { $string .= "<a href=\"/cgi-bin/pagination.pl?lang=FR&a +mp;session=1;min_index=$min_index&max_index=$max_index\" ><-$inde +x_page-></a>  "; } } $index_page++; $min_index += 40;; } $string .= "<a href=\"/cgi-bin/pagination.pl?lang=FR&session=1 +;min_index=$min_index&max_index=$max_index\" ><-\"Next\"-></a> +60; "; while (<FILE>) { s/\$ARTICLE{'index'}/$string/g; $content .= $_; } print $content; close (FILE); } sub round { my $n = shift || ''; my $r = sprintf("%.0f", $n); return $r; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^15: Need help with pagination
by Corion (Patriarch) on Jan 02, 2023 at 07:18 UTC | |
by *alexandre* (Scribe) on Jan 02, 2023 at 08:18 UTC |