From lynna@gallery44.org Fri Aug 8 20:27:04 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B6A1CD1C4C8 for ; Fri, 8 Aug 2003 20:27:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77472-02 for ; Fri, 8 Aug 2003 17:25:38 -0300 (ADT) Received: from smtp.electroniccity.org (smtp.electroniccity.org [207.219.15.18]) by svr1.postgresql.org (Postfix) with ESMTP id E7253D1C9A6 for ; Fri, 8 Aug 2003 17:26:53 -0300 (ADT) Received: from [172.16.2.153] (d2-153.electroniccity.org [172.16.2.153]) by smtp.electroniccity.org (Postfix) with ESMTP id 597AADF222 for ; Fri, 8 Aug 2003 16:20:45 -0500 (EST) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Fri, 08 Aug 2003 16:30:06 -0400 Subject: Paging results From: Lynna Landstreet To: Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/30 X-Sequence-Number: 2207 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 From busby@pnts.com Fri Aug 8 22:05:56 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DBD00D1C4DB for ; Fri, 8 Aug 2003 22:05:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 89776-02 for ; Fri, 8 Aug 2003 19:04:30 -0300 (ADT) Received: from seapdc01.PNTS (ip63.c216.blk1.bel.nwlink.com [209.20.216.63]) by svr1.postgresql.org (Postfix) with ESMTP id 6207AD1C4C8 for ; Fri, 8 Aug 2003 19:05:45 -0300 (ADT) Received: from busbydev (BUSBY-DEV [10.0.0.17]) by seapdc01.PNTS with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id PRCQ9P0P; Fri, 8 Aug 2003 15:22:31 -0700 Message-ID: <001301c35df8$4a5123d0$1100000a@busbydev> Reply-To: "David Busby" From: "David Busby" To: "Lynna Landstreet" , References: Subject: Re: Paging results Date: Fri, 8 Aug 2003 14:59:07 -0700 Organization: Pacific Northwest Ticket Service MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/31 X-Sequence-Number: 2208 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 "|Back 30"; echo "|Next 30"; // Query $rs = pg_exec($db,"select id,name from stuff order by name offset $offset limit 30;"); /B ----- Original Message ----- From: "Lynna Landstreet" To: 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 From angelo_rigo@yahoo.com.br Mon Aug 11 17:31:58 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 37A72D1C4E7 for ; Mon, 11 Aug 2003 17:31:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17163-06 for ; Mon, 11 Aug 2003 14:30:27 -0300 (ADT) Received: from web14808.mail.yahoo.com (web14808.mail.yahoo.com [216.136.224.224]) by svr1.postgresql.org (Postfix) with SMTP id DC252D1C4BA for ; Mon, 11 Aug 2003 14:31:46 -0300 (ADT) Message-ID: <20030811173147.77918.qmail@web14808.mail.yahoo.com> Received: from [200.219.69.252] by web14808.mail.yahoo.com via HTTP; Mon, 11 Aug 2003 14:31:47 ART Date: Mon, 11 Aug 2003 14:31:47 -0300 (ART) From: =?iso-8859-1?q?=C2ngelo=20Marcos=20Rigo?= Subject: Re: Paging results To: David Busby , Lynna Landstreet , pgsql-php@postgresql.org In-Reply-To: <001301c35df8$4a5123d0$1100000a@busbydev> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/37 X-Sequence-Number: 2214 I have this script (please adapt the section where the results are showed)
"; echo ""; echo ""; echo ""; echo ""; while ($row = pg_fetch_array($result, $i)) { echo ""; */ echo "$row[$j]"; //echo " $j['autor']"; } echo ""; //echo "
"; } echo "
AutorTitulo
"; //$arr = pg_fetch_array($result,($i)); for ($j=0; $j < count($row); $j++) { /* echo "
"; echo "$row[$j] "; echo "
"; // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } echo ""; // next we need to do the links to other results if (pages!=1) { if ($pgnum==1) { print "PREV   \n"; } else { $prevoffset=$offset-20; $cpgnum = intval($prevoffset/$limit)+1; print "PREV   \n"; } } for ($i=1;$i<=$pages;$i++) { // loop thru $newoffset=$limit*($i-1); $cpgnum = $i; print "$cpgnum   \n"; } // check to see if last page if ($pages!=1) { if ($pgnum<$pages) { $newoffset=$offset+$limit; $cpgnum = intval(($offset+$limit)/$limit)+1; print "NEXT

\n"; } else { print "NEXT

\n"; } } // Close database. pg_close($conn); ?> --- David Busby escreveu: > 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 "| href='/contents.php?".$qs."offset=".($offset-30)."'>Back > 30"; > echo "| href='/contents.php?".$qs."offset=".($offset+30)."'>Next > 30"; > // Query > $rs = pg_exec($db,"select id,name from stuff order > by name offset $offset > limit 30;"); > > /B > > > ----- Original Message ----- > From: "Lynna Landstreet" > To: > 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 > > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend ===== Ângelo Marcos Rigo AMR Informática (51) 3348 0870 Rua Pe. Alois Kades 400/210 Porto Alegre /RS/Brasil http://amr.freezope.org angelo_rigo@yahoo.com.br _______________________________________________________________________ Conheça o novo Cadê? - Mais rápido, mais fácil e mais preciso. Toda a web, 42 milhões de páginas brasileiras e nova busca por imagens! http://www.cade.com.br From angelo_rigo@yahoo.com.br Mon Aug 11 17:32:00 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1D501D1C513 for ; Mon, 11 Aug 2003 17:32:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 16872-07 for ; Mon, 11 Aug 2003 14:30:29 -0300 (ADT) Received: from web14803.mail.yahoo.com (web14803.mail.yahoo.com [216.136.224.219]) by svr1.postgresql.org (Postfix) with SMTP id 5D6C1D1C4DB for ; Mon, 11 Aug 2003 14:31:48 -0300 (ADT) Message-ID: <20030811173148.66610.qmail@web14803.mail.yahoo.com> Received: from [200.219.69.252] by web14803.mail.yahoo.com via HTTP; Mon, 11 Aug 2003 14:31:48 ART Date: Mon, 11 Aug 2003 14:31:48 -0300 (ART) From: =?iso-8859-1?q?=C2ngelo=20Marcos=20Rigo?= Subject: Re: Paging results To: David Busby , Lynna Landstreet , pgsql-php@postgresql.org In-Reply-To: <001301c35df8$4a5123d0$1100000a@busbydev> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/36 X-Sequence-Number: 2213 I have this script (please adapt the section where the results are showed)
"; echo ""; echo ""; echo ""; echo ""; while ($row = pg_fetch_array($result, $i)) { echo ""; */ echo "$row[$j]"; //echo " $j['autor']"; } echo ""; //echo "
"; } echo "
AutorTitulo
"; //$arr = pg_fetch_array($result,($i)); for ($j=0; $j < count($row); $j++) { /* echo "
"; echo "$row[$j] "; echo "
"; // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } echo ""; // next we need to do the links to other results if (pages!=1) { if ($pgnum==1) { print "PREV   \n"; } else { $prevoffset=$offset-20; $cpgnum = intval($prevoffset/$limit)+1; print "PREV   \n"; } } for ($i=1;$i<=$pages;$i++) { // loop thru $newoffset=$limit*($i-1); $cpgnum = $i; print "$cpgnum   \n"; } // check to see if last page if ($pages!=1) { if ($pgnum<$pages) { $newoffset=$offset+$limit; $cpgnum = intval(($offset+$limit)/$limit)+1; print "NEXT

\n"; } else { print "NEXT

\n"; } } // Close database. pg_close($conn); ?> --- David Busby escreveu: > 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 "| href='/contents.php?".$qs."offset=".($offset-30)."'>Back > 30"; > echo "| href='/contents.php?".$qs."offset=".($offset+30)."'>Next > 30"; > // Query > $rs = pg_exec($db,"select id,name from stuff order > by name offset $offset > limit 30;"); > > /B > > > ----- Original Message ----- > From: "Lynna Landstreet" > To: > 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 > > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend ===== Ângelo Marcos Rigo AMR Informática (51) 3348 0870 Rua Pe. Alois Kades 400/210 Porto Alegre /RS/Brasil http://amr.freezope.org angelo_rigo@yahoo.com.br _______________________________________________________________________ Conheça o novo Cadê? - Mais rápido, mais fácil e mais preciso. Toda a web, 42 milhões de páginas brasileiras e nova busca por imagens! http://www.cade.com.br From angelo_rigo@yahoo.com.br Mon Aug 11 18:14:51 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B436FD1C4E7 for ; Mon, 11 Aug 2003 18:14:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 26595-06 for ; Mon, 11 Aug 2003 15:13:20 -0300 (ADT) Received: from web14805.mail.yahoo.com (web14805.mail.yahoo.com [216.136.224.221]) by svr1.postgresql.org (Postfix) with SMTP id CE501D1C4DB for ; Mon, 11 Aug 2003 15:14:39 -0300 (ADT) Message-ID: <20030811181439.68382.qmail@web14805.mail.yahoo.com> Received: from [200.219.69.252] by web14805.mail.yahoo.com via HTTP; Mon, 11 Aug 2003 15:14:39 ART Date: Mon, 11 Aug 2003 15:14:39 -0300 (ART) From: =?iso-8859-1?q?=C2ngelo=20Marcos=20Rigo?= Subject: Re: Paging results To: Lynna Landstreet , pgsql-php@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/38 X-Sequence-Number: 2215 Do you have PEAR? There is in http://pear.php.net/package-info.php?package=DB_Pager, the dbpager package, wich works very well --- Lynna Landstreet escreveu: > 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 ===== Ângelo Marcos Rigo AMR Informática (51) 3348 0870 Rua Pe. Alois Kades 400/210 Porto Alegre /RS/Brasil http://amr.freezope.org angelo_rigo@yahoo.com.br _______________________________________________________________________ Conheça o novo Cadê? - Mais rápido, mais fácil e mais preciso. Toda a web, 42 milhões de páginas brasileiras e nova busca por imagens! http://www.cade.com.br From gerd@MplusB.de Tue Aug 12 18:28:23 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A60E8D1C4CC for ; Tue, 12 Aug 2003 18:28:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00698-03 for ; Tue, 12 Aug 2003 15:26:50 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id 127AAD1F52C for ; Tue, 12 Aug 2003 15:25:42 -0300 (ADT) Received: from lighthouse.MplusB.de (lighthouse.MplusB.de [193.102.49.10]) by www.postgresql.com (Postfix) with ESMTP id D68DDCF7AA8 for ; Tue, 12 Aug 2003 04:08:28 -0300 (ADT) Received: from [193.102.49.130] (helo=compass.MplusB.de) by lighthouse.MplusB.de with esmtp (Exim 3.35 #1 (Debian)) id 19mTDL-00073t-00; Tue, 12 Aug 2003 09:05:03 +0200 Received: from MplusB.de (gerd@sloop.MplusB.de [193.102.49.177]) by compass.MplusB.de (8.9.3p2/8.9.3/Debian 8.9.3-21) with ESMTP id JAA31693; Tue, 12 Aug 2003 09:05:03 +0200 X-Authentication-Warning: compass.MplusB.de: Host gerd@sloop.MplusB.de [193.102.49.177] claimed to be MplusB.de Message-ID: <3F38919E.109@MplusB.de> Date: Tue, 12 Aug 2003 09:05:02 +0200 From: Gerd Terlutter User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.0.2) Gecko/20030401 Debian/1.0.2-2 X-Accept-Language: de-de MIME-Version: 1.0 To: =?ISO-8859-1?Q?=C2ngelo_Marcos_Rigo?= Cc: Lynna Landstreet , pgsql-php@postgresql.org Subject: Re: Paging results References: <20030811181439.68382.qmail@web14805.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by compass.MplusB.de id JAA31693 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/45 X-Sequence-Number: 2222 =C2ngelo Marcos Rigo wrote: > Do you have PEAR? >=20 > There is in > http://pear.php.net/package-info.php?package=3DDB_Pager, > the dbpager package, wich works very well >>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 Hi all, PEAR is general a good idea. I use PEAR::DB as wrapper for access do=20 different RDBMS, in my case PG and MySQL. nxet week i'll start with=20 transaction on MySQL3.23.51, but don't know what happends. Other=20 functionality is given during use PEAR::DB. This package supports 10 or=20 12 RDBMS. To convert MySQL to PG try this: http://ns2.ziet.zhitomir.ua/~fonin/projects/my2pg/my2pg_man.html Another good tipp is this: http://www.rot13.org/~dpavlin/sql.html If you have a good config-file for your source, you can switch by=20 changing only the param 'dbtype' e.g. psql or mysql. excuse my bad english, Gerd --=20 -------------------------------------------------------- # Gerd Terlutter | Mueller+Blanck Software GmbH # # gerd@MplusB.de | Gutenbergring 38 # # gerd.terlutter@web.de | D-22848 Noderstedt # # tel:0171/6992579 | tel:+49 40 500 171-1 # # Buero:040/500171-17 | fax:+49 40 500 171-71 # -------------------------------------------------------- From gerd@MplusB.de Tue Aug 12 18:27:44 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8984AD1F438 for ; Tue, 12 Aug 2003 18:27:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 99597-06 for ; Tue, 12 Aug 2003 15:26:11 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id 1DFF9D1F4D6 for ; Tue, 12 Aug 2003 15:25:37 -0300 (ADT) Received: from lighthouse.MplusB.de (lighthouse.MplusB.de [193.102.49.10]) by www.postgresql.com (Postfix) with ESMTP id A4C12CF7B55 for ; Tue, 12 Aug 2003 04:15:37 -0300 (ADT) Received: from [193.102.49.130] (helo=compass.MplusB.de) by lighthouse.MplusB.de with esmtp (Exim 3.35 #1 (Debian)) id 19mTNZ-000751-00; Tue, 12 Aug 2003 09:15:37 +0200 Received: from MplusB.de (gerd@sloop.MplusB.de [193.102.49.177]) by compass.MplusB.de (8.9.3p2/8.9.3/Debian 8.9.3-21) with ESMTP id JAA31759; Tue, 12 Aug 2003 09:15:37 +0200 X-Authentication-Warning: compass.MplusB.de: Host gerd@sloop.MplusB.de [193.102.49.177] claimed to be MplusB.de Message-ID: <3F389419.5050606@MplusB.de> Date: Tue, 12 Aug 2003 09:15:37 +0200 From: Gerd Terlutter User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.0.2) Gecko/20030401 Debian/1.0.2-2 X-Accept-Language: de-de MIME-Version: 1.0 To: =?ISO-8859-1?Q?=C2ngelo_Marcos_Rigo?= Cc: Lynna Landstreet , pgsql-php@postgresql.org Subject: Re: Paging results References: <20030811181439.68382.qmail@web14805.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by compass.MplusB.de id JAA31759 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/43 X-Sequence-Number: 2220 =C2ngelo Marcos Rigo wrote: > Do you have PEAR? >=20 getting started with pear: root@home#lynx -source http://go-pear.org | php you can run for test as normal user, than you have to configure the=20 variables bin_dir, doc_dir, data_dir and php_dir. Set this to your home,=20 you'll get a running pear-system. greetings, Gerd --=20 -------------------------------------------------------- # Gerd Terlutter | Mueller+Blanck Software GmbH # # gerd@MplusB.de | Gutenbergring 38 # # gerd.terlutter@web.de | D-22848 Noderstedt # # tel:0171/6992579 | tel:+49 40 500 171-1 # # Buero:040/500171-17 | fax:+49 40 500 171-71 # -------------------------------------------------------- From lynna@gallery44.org Wed Aug 13 23:05:24 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3281ED1C4D0 for ; Wed, 13 Aug 2003 23:05:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 87012-03 for ; Wed, 13 Aug 2003 20:03:49 -0300 (ADT) Received: from smtp.electroniccity.org (smtp.electroniccity.org [207.219.15.18]) by svr1.postgresql.org (Postfix) with ESMTP id 3AF47D1B53A for ; Wed, 13 Aug 2003 20:05:12 -0300 (ADT) Received: from [172.16.2.153] (d2-153.electroniccity.org [172.16.2.153]) by smtp.electroniccity.org (Postfix) with ESMTP id 16A5FDF209; Wed, 13 Aug 2003 18:58:24 -0500 (EST) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Wed, 13 Aug 2003 19:08:26 -0400 Subject: Re: Paging results From: Lynna Landstreet To: =?ISO-8859-1?B?wg==?=ngelo Marcos Rigo , Message-ID: In-Reply-To: <20030811181439.68382.qmail@web14805.mail.yahoo.com> Mime-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/53 X-Sequence-Number: 2230 on 8/11/03 2:14 PM, =C2ngelo Marcos Rigo at angelo_rigo@yahoo.com.br wrote: > Do you have PEAR? >=20 > There is in > http://pear.php.net/package-info.php?package=3DDB_Pager, > the dbpager package, wich works very well I'd never heard of it before - I'm fairly new to PHP. I just looked through the documentation a bit, but I'm a bit confused - is this something I can actually install on my own, in the gallery's home directory, or is it something that our web host would have to install? We don't have our own server; we're just a on a shared hosting plan. Lynna --=20 Resource Centre Database Coordinator Gallery 44 www.gallery44.org From lynna@gallery44.org Wed Aug 13 23:09:38 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C7CF5D1B53A for ; Wed, 13 Aug 2003 23:09:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77664-09 for ; Wed, 13 Aug 2003 20:08:04 -0300 (ADT) Received: from smtp.electroniccity.org (smtp.electroniccity.org [207.219.15.18]) by svr1.postgresql.org (Postfix) with ESMTP id DD190D1B52C for ; Wed, 13 Aug 2003 20:09:27 -0300 (ADT) Received: from [172.16.2.153] (d2-153.electroniccity.org [172.16.2.153]) by smtp.electroniccity.org (Postfix) with ESMTP id 7890DDF209; Wed, 13 Aug 2003 19:02:41 -0500 (EST) User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Wed, 13 Aug 2003 19:12:43 -0400 Subject: Re: Paging results From: Lynna Landstreet To: =?ISO-8859-1?B?wg==?=ngelo Marcos Rigo , Message-ID: In-Reply-To: <20030811173147.77918.qmail@web14808.mail.yahoo.com> Mime-version: 1.0 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/54 X-Sequence-Number: 2231 on 8/11/03 1:31 PM, =C2ngelo Marcos Rigo at angelo_rigo@yahoo.com.br wrote: > I have this script (please adapt the section where the > results are showed) Thank you very much - I've implemented this on one of my results pages as a test, and it seems to be partially working - the results are limited properly, and there are no errors, but the next and previous links aren't quite working right. On the first page, the prev link points to offset 0 and page 1, which I guess is correct, but the next link leaves offset blank, and has page 0, instead of having offset 50 (that's what I set $limit to) and page 2 as I would think it should. If I enter those values manually in the URL - http://www.gallery44.org/db/artists_browse_paged.php?offset=3D50&pgnum=3D2 = - the second page displays correctly, but again the prev and next links don't work right. The prev page here shows pgnum=3D1, which is correct, but it shows offset as 30 when it should be 50. And the next link shows exactly what it did on page 1 - offset=3D&pgnum=3D0. I've looked at the code, but I don't t= hink I'm following it well enough to be sure what's going wrong. I've attached a copy of the file=20 I kept the code pretty much as it was except for the part where the results are displayed, and a couple of very minor tweaks (changed the pg_query and pg_num_rows to pg_exec and pg_numrows because I'm using PHP 4.1, changed the part where it selects the whole table and uses pg_numrows to count it to a select count because it seemed more efficient, and changed $conn to the database connection I'd already opened, $db). If you or anyone else could suggest what might be going wrong, I'd very much appreciate it. Here's what I've got: First part (before displaying query results): // Paging script - request for parameters. $offset =3D $_REQUEST['offset']; $pgnum =3D $_REQUEST['pgnum']; =20=20=20=20 // Make that they are integer - security. settype($offset, 'integer'); settype($pgnum, 'integer'); =20=20=20=20 // Open database, i.e PostgreSQL if (!$db) { echo "An error occured - no database connection exists.\n"; exit;=20 }=20 =20=20=20=20 // Initialize variables. $limit=3D50; // rows to return $numresults=3Dpg_exec("SELECT COUNT(*) FROM artists"); //PostgreSQL // $numrows=3Dpg_numrows($numresults); =20=20=20=20 // next determine if offset has been passed to script, if not use 0 if (empty($offset)) { $offset=3D0;=20 $pgnum=3D1;=20 }=20 Then comes the display of the results, which is working fine. Second part: // calculate number of pages needing links $pages=3Dintval($numrows/$limit); =20=20=20=20 // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { =20=20=20=20=20=20=20=20 // has remainder so add one page $pages++; }=20 =20=20=20=20 echo "\n

"; // next we need to do the links to other results if (pages!=3D1) {=20 if ($pgnum=3D=3D1) { print "PREV   \n";=20 }=20 else=20 {=20 $prevoffset=3D$offset-20; $cpgnum =3D intval($prevoffset/$limit)+1; print "PREV   \= n"; }=20 }=20 =20=20=20=20 for ($i=3D1;$i<=3D$pages;$i++) { // loop thru $newoffset=3D$limit*($i-1); $cpgnum =3D $i; print "$cpgnum  = \n"; }=20 =20=20=20=20 // check to see if last page if ($pages!=3D1) {=20 if ($pgnum<$pages) { $newoffset=3D$offset+$limit; $cpgnum =3D intval(($offset+$limit)/$limit)+1; print "NEXT

\n"; =20=20=20=20 }=20 else=20 {=20 print "NEXT

\n"; =20=20=20=20 }=20 }=20 Many thanks, Lynna --=20 Resource Centre Database Coordinator Gallery 44 www.gallery44.org From scott.marlowe@ihs.com Thu Aug 14 14:29:14 2003 X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A9141D1F4AA for ; Thu, 14 Aug 2003 14:29:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 36884-07 for ; Thu, 14 Aug 2003 11:27:39 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 60D2FD1F43A for ; Thu, 14 Aug 2003 11:28:31 -0300 (ADT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h7EER25p003263; Thu, 14 Aug 2003 08:27:02 -0600 (MDT) Date: Thu, 14 Aug 2003 08:27:43 -0600 (MDT) From: "scott.marlowe" To: Lynna Landstreet Cc: =?ISO-8859-1?B?wg==?=ngelo Marcos Rigo , Subject: Re: Paging results In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/57 X-Sequence-Number: 2234 On Wed, 13 Aug 2003, Lynna Landstreet wrote: > on 8/11/03 2:14 PM, Ângelo Marcos Rigo at angelo_rigo@yahoo.com.br wrote: > > > Do you have PEAR? > > > > There is in > > http://pear.php.net/package-info.php?package=DB_Pager, > > the dbpager package, wich works very well > > I'd never heard of it before - I'm fairly new to PHP. I just looked through > the documentation a bit, but I'm a bit confused - is this something I can > actually install on my own, in the gallery's home directory, or is it > something that our web host would have to install? We don't have our own > server; we're just a on a shared hosting plan. PEAR, and about 12 or so other packages, are usually distributed with PHP and found in the /usr/local/lib/php directory on most Unix boxes.