From: David Busby <busby@pnts.com>
To: Lynna Landstreet <lynna@gallery44.org>
To: pgsql-php@postgresql.org
Subject: Re: Paging results
Date: Fri, 8 Aug 2003 14:59:07 -0700
Message-ID: <001301c35df8$4a5123d0$1100000a@busbydev> (raw)
References: <BB59808E.929%lynna@gallery44.org>
Paging with PostgreSQL is super easy!
select * from table where (x=y) offset 0 limit 30;
Gives you the first 30 matches, then do
select * from table where (x=y) offset 30 limit 30;
This will give the next 30, super easy!
Here's a sample of how I use it in a script
// Collect offset
$offset = isset($_GET['offset'])?$_GET['offset']:0;
// Now the links for Prev/Next
if ($offset >= 30) echo "|<a
href='/contents.php?".$qs."offset=".($offset-30)."'>Back 30</a>";
echo "|<a href='/contents.php?".$qs."offset=".($offset+30)."'>Next 30</a>";
// Query
$rs = pg_exec($db,"select id,name from stuff order by name offset $offset
limit 30;");
/B
----- Original Message -----
From: "Lynna Landstreet" <lynna@gallery44.org>
To: <pgsql-php@postgresql.org>
Sent: Friday, August 08, 2003 13:30
Subject: [PHP] Paging results
> HI there,
>
> Thanks to everyone who helped with my keyword problem - I think I thanked
> them all individually but I thought I should mention it here too.
>
> Now, a new question:
>
> Does anyone know if there's a PHP class anywhere out there for paging
> results from a PostgreSQL query, similar to Paginator or ezResults which
do
> that for MySQL? Or do I have to do the code for that from scratch?
>
> Alternatively, would it be difficult to adapt one of those to working with
> PostgreSQL instead of MySQL?
>
>
> Lynna
> --
> Resource Centre Database Coordinator
> Gallery 44
> www.gallery44.org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: busby@pnts.com, lynna@gallery44.org
Subject: Re: Paging results
In-Reply-To: <001301c35df8$4a5123d0$1100000a@busbydev>
References: <BB59808E.929%lynna@gallery44.org> <001301c35df8$4a5123d0$1100000a@busbydev>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox