previous & next buttons

P

Psybar Phreak

hi all,

im developing a site in perl with mason on a postgreSQL backend.

i currently have a page that lists all items in a table, but would like to
do the
" << PREVIOUS 1 2 3 4 NEXT>> "

sort of thing - say LIMIT of 10 records to a page.

can someone help me out.

thanks

PP
 
D

dw

anyone? like

how about something along the lines of:

$q = new CGI;

$start = $q->param("start") || 0;

$count = 0;
while ($db->fetch) {
$count ++;
next while $count < $start;
last if $count = $start + 10;
print "item $count : **whatever you normally do**";
}

$MAX = $total_number_of_records_in_db;

print $q->a({href=>"?...&start=" . $start-10}, "<< PREVIOUS"), " ";
print $q->a({href=>"?...&start=" . ($_ * 10 + 1)}, "$_"), " " for
1..($MAX/10);
print $q->a({href=>"?...&start=" . $start+10}, "NEXT >>");


that should give you an idea on how you can do it... and if you can tell
your db to start at record number $start, that would be even better...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top