Re: best way to get COUNT from result set

From: Date: Wed, 20 Dec 2000 00:49:22 +0000
Subject: Re: best way to get COUNT from result set
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31109@lists.php.net to get a copy of this message
Use mysql_result: replace the $count line with: $count = mysql_result($rslt,0,0); Then you should be able to access the value just using $count. For more info: http://www.php.net/manual/function.mysql-result.php Matthew At 10:26 PM 12/19/2000 -0200, you wrote:
there's no way to get a single result from a query (since several functions like MAX(), AVG(), COUNT(), ...) return single values... I could go like... $q = "select count(id) from table"; $rslt = mysql_query($q); $count = mysql_fetch_row($rslt); and then $count[0] would have what I want... but this is kinda "syntax ugly"... I only want ONE value... I don't want an ARRAY... of course $count = $count[0] (I'm sure a lot of people would sugest that) is possible, but is also "syntax ugly"... is there any way around this? ____________________________ . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#31109) next »