Hi,
What exactly is it that you want to do?
Are you looking for a way to use mysql in perl, a way to determine and insert nex/previous links, or BOTH?
To use mysql, you can download a CPAN module. Here is a link:
http://search.cpan.org/search?dist=DBD-mysql
You can use the search on that CPAN site to find alternate modules.
To insert next/previous links, here is a sample code...
NOTE: I pulled this first excerpt right from the manual page for DBD::MySQL and edited it to add in the next/previous stuff:
# initialize the database
$dbh = ...
# Set the below variable so that you get this number from the URL's GET data
# I set it to a default for now
$startingrow = 10;
if($startingrow > 0) {
# print the previous link... we want to increment/decrement by 10. change it if you like
print "<a href=\"script.php?startingrow=" . ($startingrow - 10) . "\">Previous</a>";
}
# again, the increment is 10, but i put in 11 so that we know whether there are more (next) rows
my $sth = $dbh->prepare("SELECT * FROM foo LIMIT $startingrow,11");
$sth->execute();
$count = 1;
while ( (my $ref = $sth->fetchrow_hashref()) && ($count < 11) ) {
print "Row $count: id = $ref->{'id'}, name = $ref->{'name'}\n";
$count++;
}
$sth->finish();
if( ($ref = $sth->fetchrow_hashref()) !== false) {
#there exists a 11th row
print "<a href=\"script.php?startingrow=" . ($startingrow + 10) . "\">Next</a>";
}
I haven't tested this code since it came off the top of my head. Please refer to the manual for the perl module you are using and fix any errors you notice.
As far as perl forums: i haven't used one in over 3 years. there were some good ones linked from the perl.com resource pages. But now the perl.com site has changed so much, i rarely go there anymore :-(
-sridhar