CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
[SOLVED] Need help to improve pagination

 

First page Previous page 1 2 Next page Last page  View All


Zhris
Enthusiast

Aug 6, 2014, 11:48 AM

Post #26 of 35 (1083 views)
Re: [terrykhatri531] Need help to improve pagination [In reply to] Can't Post

Cool, did it work Laugh?

Note that using the window. prefix is probably better practice: http://stackoverflow.com/questions/19423513/is-there-any-difference-with-using-only-location-vs-using-window-location-across.

In future though, please post the cross link too so that work isn't duplicated.

Chris


(This post was edited by Zhris on Aug 6, 2014, 11:51 AM)


terrykhatri531
User

Aug 6, 2014, 12:19 PM

Post #27 of 35 (1075 views)
Re: [Zhris] Need help to improve pagination [In reply to] Can't Post

Yes it worked !! The only difference is of word "window" if add it to the code, for some reason the jpaginator disappears from the web page, I will look into it later on as to why.

Sorry BUT there is one more outstanding issue with my pagination, if you look at my perl code in the above comment or the script attached in one of the comments, my pagination starts with 0 (Zero) because of the offset parameter as for the first page the offset has to be 0 while the jquery paginators start with 1.

Will have to do some perl hacking to get around this issue !!!



Thanks much Chris !!

Terry


Zhris
Enthusiast

Aug 6, 2014, 12:27 PM

Post #28 of 35 (1073 views)
Re: [terrykhatri531] Need help to improve pagination [In reply to] Can't Post

Hmm thats strange, I might throw an example together later and see if I encounter the same issue, but nonetheless you have it working!

I don't understand your last issue, it seems like its a simple case of adding 1 to your variable in certain instances?


Code
for (0 .. 10) 
{
print $_, ", ";
print $_ + 1, "\n";
}


Chris


terrykhatri531
User

Aug 7, 2014, 1:05 AM

Post #29 of 35 (1062 views)
Re: [Zhris] Need help to improve pagination [In reply to] Can't Post

Thanks Chris,

It looks simple to you but not to me Frown I can't figure out how to make it fit in my code, your above example demonstrate what I need to do, the following line in my script determines the value of offset variable and the 'page' parameter is passed to the script based on which the offset is calculated :


Code
 
# Assigning value to $offset as 0 or whatever will be the $pagenum i.e. 1 or 2 ....
$offset=param('page')? $limit*param('page') :0;



Thanks much.

Terry


Zhris
Enthusiast

Aug 7, 2014, 9:46 AM

Post #30 of 35 (1050 views)
Re: [terrykhatri531] Need help to improve pagination [In reply to] Can't Post

I must keep insisting that you use Data::Page!


Code
$entries_per_page = 10 unless ($entries_per_page =~ m/^[1-9]\d*$/); 

my $page = Data::Page->new;

$page->total_entries($total_entries);
$page->entries_per_page($entries_per_page);
$page->current_page($current_page);

# pageset
my $first_page = $page->first_page; # should always be 1.
my $last_page = $page->last_page;

# resultset
my $offset = $page->first - 1; # will be 0 if on first page.
my $limit = $page->entries_on_this_page;


Chris


(This post was edited by Zhris on Aug 7, 2014, 9:53 AM)


FishMonger
Veteran / Moderator

Aug 7, 2014, 11:29 AM

Post #31 of 35 (1040 views)
Re: [Zhris] Need help to improve pagination [In reply to] Can't Post


In Reply To
I must keep insisting that you use Data::Page!
Chris


No, he can't do that because it would be too easy and logical. :)


(This post was edited by FishMonger on Aug 7, 2014, 11:30 AM)


Zhris
Enthusiast

Aug 7, 2014, 12:58 PM

Post #32 of 35 (1032 views)
Re: [FishMonger] Need help to improve pagination [In reply to] Can't Post

Laugh


Code
my $i = 0; 
while ( $i < 10 )
{
$i = $i + 1;
}
# do something with $i.



Laurent_R
Veteran / Moderator

Aug 7, 2014, 1:07 PM

Post #33 of 35 (1026 views)
Re: [Zhris] Need help to improve pagination [In reply to] Can't Post


In Reply To
Laugh


Code
my $i = 0; 
while ( $i < 10 )
{
$i = $i + 1;
}
# do something with $i.



You forgot the $j and $k variables:


Code
my $i = 0; my ($j, $k); 
while ( $i < 10 )
{
$i = $i + 1;
$j--;
$k = 2 * $i + $j;
}
($j, $k) = (0, 0);
# do something with $i.


Laugh


Zhris
Enthusiast

Aug 7, 2014, 1:27 PM

Post #34 of 35 (1020 views)
Re: [Laurent_R] Need help to improve pagination [In reply to] Can't Post

I knew I had missed something! The only improvement I made was to change $j and $k for $a and $b Angelic.


terrykhatri531
User

Aug 8, 2014, 8:56 AM

Post #35 of 35 (995 views)
[SOLVED] Need help to improve pagination [In reply to] Can't Post

Thanks very very much Chris for all your help!!! I am done and over with pagination.

Rgds.

Terry

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives