Re: best way to get COUNT from result set
| From: | Philip Hallstrom | Date: | Wed, 20 Dec 2000 00:31:04 +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-31108@lists.php.net to get a copy of this message | ||
Write a function that does it... something like:
mysql_fetch_one($query);
And then put the stuff below in the function...
On Tue, 19 Dec 2000, Christian Dechery 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
>