|
Posted by bill on 12/31/06 16:25
Andy Hassall wrote:
> On Sun, 31 Dec 2006 10:32:02 -0500, bill <nobody@spamcop.net> wrote:
>
>> Andy Hassall wrote:
>>> On Sat, 30 Dec 2006 17:04:58 -0500, bill <nobody@spamcop.net> wrote:
>>>
>>>> I am sure there must be an easy way to determine the number of
>>>> rows in a table, but I can't find it.
>>>>
>>>> I appreciate the courtesy and patience ng members have shown this
>>>> mysql novice.
>>> select count(*) from your_table
>> $total_rows = mysql_query ("SELECT COUNT(*) FROM Kennel");
>>
>> gives me a resource, not the count.
>>
>> Fine, so I use:
>>
>> $total_rows = mysql_query ("SELECT COUNT(*) FROM Kennel");
>> echo "Rows in table: " . mysql_num_rows ($total_rows) . "<br />";
>>
>> but that returns 1, and there are 4 rows in the table.
>
> The query gives a 1 column result set with 1 row, which will have the count in
> it. mysql_num_rows gives you the number of rows in a result set - therefore
> it's 1 here.
>
> If you fetched the first row with mysql_fetch_array or one of the variants of
> it then you can get at the value for the first column in the row - which will
> be 4.
>
Ah, works like a charm.
Thanks. I appreciate your assistance a lot.
bill
[Back to original message]
|