Re: Pagination II



webmaster@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 ) );

.



Relevant Pages

  • Efficiency
    ... I wrote a script that built the SQL to examine text fields using a LIKE ... but for some reason or other I couldn't get it to work. ...
    (microsoft.public.access.queries)
  • Re: $ENV{CONTENT_LENGTH} / STDIN
    ... >> reason for a form in the first place. ... than about every other aspect of writing a script. ... > insecure may be perfect in the lab, but useless in the real world. ... hard-coded validation, rather than hard-coded names. ...
    (comp.lang.perl.misc)
  • Re: Is there a correct place to put javascript within a html file?
    ... The HTML specification tells you where script elements are permitted: ... script files have downloaded and if they're all in the head ... ... like the sensible thing to do; at least there's a reason for it. ... javascript is positioned just before the then the various html ...
    (comp.lang.javascript)
  • Re: Barbara Thiering Refuted!
    ... the particular script. ... John Byrne did. ... THIS HYPOTHESIS for the reason...what was the reason, ... capable of looking up the straight lines and crunching the numbers. ...
    (sci.archaeology)
  • Re: Barbara Thiering Refuted!
    ... the particular script. ... John Byrne did. ... THIS HYPOTHESIS for the reason...what was the reason, ... capable of looking up the straight lines and crunching the numbers. ...
    (sci.archaeology)