Re: Pagination II



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?

.



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)
  • XP_cmdShell Error
    ... I am trying to below script on BOX1 ... But it is Blowing with below error. ... Reason: Not associated ... with a trusted SQL ...
    (microsoft.public.sqlserver.server)
  • Loging Script
    ... It seems there is something wrong with my script for the reason that ... it always returns, UserName NOT found. ... $sql = check; ...
    (comp.lang.php)
  • Re: Pagination II
    ... script runs and always goes to page 2 for some reason. ... Can anyone spot the problem? ... print $sql; ...
    (comp.lang.perl.misc)
  • RE: Backups have Shadow Copy Problems
    ... Active backup destination: File ... Reason: The process cannot access the file because it is being used by ... Warning: Unable to open "C:\Documents and Settings\Administrator\Local ... Warning: Unable to open "C:\Program Files\Microsoft SQL ...
    (microsoft.public.windows.server.sbs)