> I want to write a subroutine to select the contain of MySQL database and
> display the result on the browser.
> But I'm not sure how to get it create multiple pages if the list exceeds
> a given number; say 50, and create a link to the next page: like "Next"
> or "1 2 3". I think it should be easy - but I've never seen codes like
> that before.

The idea is you create a ranged loop.

for (x..x+y) {
  #blah
}

#blah is where you put all your code for retrieving lines from the SQL dbase
and HTMLize them and return them.

x is obtained through CGI params

my $q = new CGI;
my $start = $q->param('start');

x+y is obtained however

1-
my $end = $start + $q->param('amount_per_page');
2-
my $end = $start + 50;

whichever.

Then;

for ($start..$end) {
    #grab from db, htmllize, append to scalar variable...
}


print <<EOF;
<center>
<table>
$scalar_from_for_loop
</table>
</center>
EOF

and, yeah...

Should put you on the right track.  I wrote my own customized interface to SQL
(actually its an interface to the normal DBI interface, heh..) so I didn't
write that portion since what I use would not at all be like what you would
use.

Dennis


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to