Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 291C19FBB45 for ; Wed, 28 Mar 2007 18:06:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 48243-01 for ; Wed, 28 Mar 2007 18:05:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp1.execulink.net (smtp1.execulink.net [69.63.44.82]) by postgresql.org (Postfix) with ESMTP id E26049FB9AC for ; Wed, 28 Mar 2007 18:05:54 -0300 (ADT) Received: from acer.sympatico.ca (node-6114.tor.pppoe.execulink.com [67.158.71.227]) by smtp1.execulink.net (8.13.1/8.12.11) with ESMTP id l2SL8CC8022472 for ; Wed, 28 Mar 2007 17:08:12 -0400 Message-Id: <5.2.1.1.0.20070328164533.009fcdc0@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 Date: Wed, 28 Mar 2007 17:03:53 -0400 To: pgsql-php@postgresql.org From: Frank Bax Subject: Re: Retrieving result of COUNT(*) with PHP In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.939 tagged_above=0 required=5 tests=AWL=-0.266, BAYES_50=0.001, FORGED_RCVD_HELO=0.135, SPF_NEUTRAL=1.069 X-Spam-Level: X-Archive-Number: 200703/54 X-Sequence-Number: 3766 At 03:16 PM 3/28/07, Lynna Landstreet wrote: >I'm trying to use a SELECT COUNT(*) to count how many results would be >retrieved from a particular query (as part of the process of paginating >search results). > >But I'm having trouble figuring out how to retrieve the result of the >count in PHP. Why not simply run your query and then call pg_numrows( ) ? You didn't show us any php code - this works.. $res = pg_query( $dbc, 'SELECT COUNT(*) FROM payperiod'); $val = pg_fetch_result( $res, 0, 0 ); var_dump ($val ); might output something like string(3) "205"