Re: Count number of rows in table.

From: Date: Sun, 25 Aug 2002 14:11:46 +0000
Subject: Re: Count number of rows in table.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114053@lists.php.net to get a copy of this message
On Sunday 25 August 2002 22:07, salamander wrote: > or, you should be able to simply do this, without the cost of fetching > the results: > > $result = mysql_query("SELECT count(*) FROM table WHERE"); > $num_rows = mysql_num_rows($result); > echo "$num_rows Rows\n"; No. This only returns 1 row regardless. "SELECT COUNT(*) FROM ..." only returns a single row with a single column containing the row count. Using mysql_num_rows() on that will always return 1. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I'm going to Vietnam at the request of the White House. President Johnson says a war isn't really a war without my jokes. -- Bob Hope */

« previous php.general (#114053) next »