Hi Poj,

I have created pagination using the following code it works but does not look graceful as it displays links for all 103 pages what I need help for is to make it compact like : [First][Prev][1][2][3][4][5][6]...[103][Next][last], I have looked at perl pagination modules @ cpan but there aren't enough examples for a guy of my level to use them

# Count how many rows are there in a table, so that we can use it for +$pagenum. my $sql = qq!SELECT COUNT(*) from "Orders" !; my $sth = $dbh->prepare ("$sql"); $sth->execute() || quit(); my @row = $sth->fetchrow_array; $sth->finish; # Setting offset, limit and page number my $offset = 0; my $limit = 8; my $pagenum = ceil($row[0]/$limit); # Assigning value to $offset as 0 or whatever will be the $pagenum i.e +. 1 or 2 .... $offset=param('page')? $limit*param('page') :0; # Get the data $sql = qq!SELECT a."OrderID", b."CompanyName" AS "CustomerName", c."FirstName"::text || ' ' ||c."LastName"::text AS "E +mployeeName", a."OrderDate"::DATE, a."RequiredDate"::DATE, a."Shipp +edDate"::DATE, d."CompanyName" AS "ShipVia", a."Freight", a."ShipNam +e", a."ShipAddress", a."ShipCity", a."ShipRegion", a."ShipPostalCode", a."ShipCountry" FROM "Orders" a, "Customers" b, "Employees" c, "Shippers" +d WHERE a."CustomerID" = b."CustomerID" AND a."EmployeeID" = c."EmployeeID" AND a."ShipVia" = d."ShipperID" ORDER BY 1 LIMIT $limit OFFSET $offset !; $sth=$dbh->prepare("$sql"); $sth->execute() || quit(); .... then html stuff skiped.... # Showing page number with link my $first_page = $pagenum - $pagenum ; my $last_page = $pagenum - 1; $pagenum = $pagenum - 1; print q(<ul class="tsc_pagination tsc_paginationA tsc_paginationA09">) +; print qq(<li><a href='vieword.pl?page=$first_page'>First>); for my $i (0 .. $pagenum) { print qq(<li><a href='vieword.pl?page=$i'>$i>); } print qq(<li><a href='vieword.pl?page=$last_page'>Last>); print q(</ul>);

Your help as usual will be much appreciated.

Many thanks !

Terry

In reply to Need help to improve pagination by terrykhatri

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.