Thanks for your reply graff. The first if statement was because I parsed the form at one point. I have cleaned up the script, and got rid of anything I don't need and I am still having the same problem. I tried putting reqpage in the page links, but still no luck.

I'm thinking the problem is with the links. I am having a hard wrapping my brain on how to create these links properly and what exactly I should be putting in them. I'm sure I am close to getting this working, so any help would be much appreciated. I have attached the updated script.
Thanks in advance.

#!/usr/bin/perl use CGI qw(:standard); use DBI; use warnings; use strict; my (@row,$name,$path,$dsp,$count); my $query = new CGI; print $query->header('text/html'); print qq~ <!DOCTYPE html> <html> <head> <title>Movie Search</title> </head> <body> <br /><br />~; my $reqpage = $query->param('reqpage') || '1'; param('per_page'); #Get total amount of rows from db my $dbh=DBI->connect($connectionInfo,$user,$passwd); my $num_rows= $dbh->selectrow_array('select count(name) from video + order by name'); my $num_results_perpage = 25; # calculate the number of pages to show my $pagecount = int($num_rows / $num_results_perpage); if (($pagecount * $num_results_perpage) != $num_rows) { $pagecount++; } # calculate which results to show in the page my $firstresult = (($reqpage - 1) * $num_results_perpage) + 1; my $lastresult = $firstresult + $num_results_perpage - 1; if ($lastresult > $num_rows) { $lastresult = $num_rows; } # sql limit starts at 0 my $start_point = $firstresult - 1; my $sth = $dbh->prepare("Select name,path from video order by name + LIMIT $start_point,$num_results_perpage"); $sth->execute(); while (@row = $sth->fetchrow_array()) { $name = $row[0]; $path = $row[1]; $path =~ s/'/%27/g; $dsp = substr $path, 27, 255; print "<a href='/media/$dsp'>$name</a> <br />"; $count=$count+1; } $sth->finish(); # page links my ($prev_link, $next_link, $pagelinks, $pageno, $thislink, $pages +ize); my $prev_page = $reqpage - 1; my $next_page = $reqpage + 1; if ($reqpage == 1) { $prev_link = ""; } else { $prev_link = " <a href=\"http://path/to/script.cgi?reqpage=$re +qpage=$prev_page\">". "previous" . "</a>"; } if ($reqpage == $pagecount) { $next_link = ""; } else { $next_link = " <a href=\"http://path/to/script.cgi?reqpage=$re +qpage&page=$next_page\">". "Next" . "</a>"; } if ($pagecount > 1) { $pagelinks = $prev_link; $pageno = 0; while ($pageno < $pagecount) { $pageno++; if ($pageno == $reqpage) { $thislink = " <strong>$pageno</strong> "; } else { $thislink = " <a href=\"http://path/to/script.cgi?reqp +age=$reqpage&page=$pageno\">" . $pageno . "</a>"; } $pagelinks = $pagelinks . $thislink; } $pagelinks = $pagelinks . " " . $next_link; } else { $pagelinks = ""; } print "<br />"; print $count . "<br /><br />"; print $pagelinks . "<br />"; print "Database Results: " . $num_rows . "<br />"; print "Page " . $firstresult . " Of&nbsp;&nbsp;" . $pageno; print qq~ <br /> <br /> </body> </html>~;

In reply to Re^2: Perl Database Paging by ironside
in thread Perl Database Paging by ironside

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.