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: Advanced:
Perl Database Paging

 



jwalker
Novice

May 31, 2011, 11:45 AM

Post #1 of 7 (4814 views)
Perl Database Paging Can't Post

Hi,

I'm trying to display database results on multiple pages.
This is what I have so far:

###Set Page Results
$rows_per_page=10;
$total_pages=int( ($results/$rows_per_page) +0.99);
$offset=(($page) * $rows_per_page);
$limit=("LIMIT $offset, $rows_per_page");

foreach $i (1..$total_pages)
{
$uris{$i}="$pagel?key=value&key=value&page=$i";
}

The foreach loop is for creating the links to each page.
My question is what should the key value pairs be for the url?
Any help would be much appreciated.

Thanks.


miller
User

May 31, 2011, 2:21 PM

Post #2 of 7 (4806 views)
Re: [jwalker] Perl Database Paging [In reply to] Can't Post

What do you think the key, value pairs should be?

Do you need anything more than the 'page' reference?

- Miller


jwalker
Novice

May 31, 2011, 2:28 PM

Post #3 of 7 (4805 views)
Re: [miller] Perl Database Paging [In reply to] Can't Post

I don't think so. I just need to be able to create a link for each page result that I can put into separate hyperlink.


(This post was edited by jwalker on May 31, 2011, 2:28 PM)


miller
User

May 31, 2011, 2:38 PM

Post #4 of 7 (4801 views)
Re: [jwalker] Perl Database Paging [In reply to] Can't Post

Ok, then I think you've just answered your own question.

Kudos,
- M


jwalker
Novice

May 31, 2011, 2:43 PM

Post #5 of 7 (4800 views)
Re: [miller] Perl Database Paging [In reply to] Can't Post

I'm not sure on how to put the page references into the key value pairs though.


miller
User

May 31, 2011, 2:45 PM

Post #6 of 7 (4799 views)
Re: [jwalker] Perl Database Paging [In reply to] Can't Post

What have you tried thus far? Is there any problem with the code you originally posted?


Code
foreach $i (1..$total_pages) { 
$uris{$i}="$pagel?page=$i";
}


- M


jwalker
Novice

May 31, 2011, 2:58 PM

Post #7 of 7 (4795 views)
Re: [miller] Perl Database Paging [In reply to] Can't Post

The links work but the search results are only displayed on the first page. Any idea why that could be?

 
 


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

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