RE: [PHP] counting number of records in a MySQL table; how do I get

From: Date: Thu, 03 Oct 2002 12:43:12 +0000
Subject: RE: [PHP] counting number of records in a MySQL table; how do I get
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118727@lists.php.net to get a copy of this message
[snip] Or another way if you don't want a result when it's zero. $rslt = mysql_query("SELECT count(*) as cnt FROM tbl having cnt > 0"); [/snip] $result = mysql_query("SELECT * FROM tbl"); $number_of_rows = mysql_num_rows($result); You don't have to do the count in the SQL, as John said earlier a SELECT COUNT(*) FROM tbl will always return one row, even if the value of the row is 0. Of course you could always test for that. CountingRows Solution #317 :^] HTH! Jay ***************************************************** * Texas PHP Developers Conf Spring 2003 * * T Bar M Resort & Conference Center * * New Braunfels, Texas * * Contact jay.blanchard@niicommunications.com * * * * Want to present a paper or workshop? Contact now! * *****************************************************

« previous php.general (#118727) next »