Re: Retrieving result of COUNT(*) with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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"


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux