Re: Retrieving result of COUNT(*) with PHP

Frank Bax <[email protected]>
Newsgroups gmane.comp.db.postgresql.php
Message-ID <[email protected]>
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" 


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [email protected] so that your
       message can get through to the mailing list cleanly
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.