I think you were on the right track with your first response. Selecting
a count(*) gives you the number of rows returned without the overhead of
actually returning all of the rows to PHP. Most people will rename the
count as something more easy to reference (and/or more descriptive) in
the result set:
select count(*) as num_movies from movies where actor='Val Kilmer';
What Jason was trying to explain is that the data you are looking for is
actually in the query you performed. You specifically queried for the
number of rows. Your result set consists of a single row with a single
> okay, so then a "select *" and then a num_rows ...
> On Sunday, August 25, 2002, at 10:11 AM, Jason Wong wrote:
>> 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.
>> mysql_num_rows() on that will always return 1.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php