Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Retrieving result of COUNT(*) with PHP



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"



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group