Re: Pagination II
- From: JimJx <webmaster@xxxxxxxxxxxxxxxx>
- Date: Tue, 14 Aug 2007 12:37:52 -0000
On Aug 13, 3:34 pm, "J. Gleixner" <glex_no-s...@xxxxxxxxxxxxxxxxxxxxx>
wrote:
webmas...@xxxxxxxxxxxxxxxx wrote:
Thanks to everyone here, I am closer to getting this working but am
still having a problem....
The script runs and outputs a page, but in the db I have set up all of
the categories have enough entries to fill multiple pages. So, the
script runs and always goes to page 2 for some reason.
And if I click on one of the other links for a different page, then I
get nothing on that one.
Can anyone spot the problem?
[...]
if (!$limit) {$limit = 5;}
$limit = 5 unless defined $limit;
my $sql = "select * from valley where category like ?";
Do you really need all of the columns?
my $sth = $dbh->prepare($sql) or die("Error in SQL1\n");
$sth->execute($find) or die "Error in SQL2 $!\n";
Look at DBI's RaiseError.. Using that you
can eliminate all of your 'or die..' code.
my $results_per_page = 5;
my $sql = "select * from valley where category like ?
limit $limit, $results_per_page";
Start with your SQL, once it's correct, then print it
to make sure it's correct, then actually run it.
print $sql;
Then run it on your DB, to see what it products. It looks like
limit and results_per_page are both 5, which probably isn't
what you want.
$sth->bind_columns( \$ID, \$category, \$name, \$description, \
$contact, \$phone, \$fax, \$address, \$city, \$state, \$zip, \$email, \
$url, \$keywords );
A little more readable as:
$sth->bind_columns( \( $ID, $category, $name, ..., $keywords ) );
I made the changes that you suggested, but when I print $sql, I get
'select * from valley where category like ? limit 5, 5'
Which I can tell is definitely not what I want.....
Any suggestions on where to proceed from here?
.
- Follow-Ups:
- Re: Pagination II
- From: J. Gleixner
- Re: Pagination II
- References:
- Pagination II
- From: webmaster
- Re: Pagination II
- From: J. Gleixner
- Pagination II
- Prev by Date: Re: conditional regular expressions
- Next by Date: Re: Perl executing a command (on UNIX)
- Previous by thread: Re: Pagination II
- Next by thread: Re: Pagination II
- Index(es):
Relevant Pages
|