You are here: Re: How many rows in a table « PHP Programming Language « IT news, forums, messages
Re: How many rows in a table

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация