Re: Paging large recordsets
| From: | Peter Beckman | Date: | Fri, 13 Feb 2004 18:29:07 +0000 |
| Subject: | Re: Paging large recordsets | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32940@lists.php.net to get a copy of this message | ||
On Fri, 13 Feb 2004, Karen Resplendo wrote:
> I guess the time has come that my boss wants "Next", "Previous",
> "First",
> "Last" paging for our data displays of large recordsets or datasets.
First, do a query to find out how many rows.
select count(*) from table where (your where clauses for the query);
That's your # of records.
Then do:
select count(*) from table where (your clauses) limit ($pagenum*$itemlimit)-$itemlimit),
$itemlimit;
so if your $itemlimit = 10 items per page, and you are on page 3,
it would be ... limit 20, 10
page #1, limit 0,10 etc
> Also, how to deal with printing? I would assume that the ideal page size
> is not the ideal printed page size. oi vay!
In IE 6, this works:
<br style='page-break-after:always;'>
Even if your text follows, IE will print a page break. Haven't researched
how to do it in Mozilla or Netscape.
Beckman
---------------------------------------------------------------------------
Peter Beckman Internet Guy
beckman@purplecow.com http://www.purplecow.com/
---------------------------------------------------------------------------