|
Posted by bill on 12/31/06 15:32
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.
However,
$sql = "Select id, kennel_name, location, real_names from Kennel
ORDER BY REPLACE(kennel_name,'The ','') LIMIT 100";
$result = mysql_query($sql, $connection) or die(mysql_error());
echo "Rows in table-2: " . mysql_num_rows ($result) . "<br />";
does give the correct answer.
what am I doing wrong with the first query ?
Navigation:
[Reply to this message]
|