RE: [PHP] best way to get COUNT from result set
| From: | indrek siitan | Date: | Wed, 20 Dec 2000 10:16:00 +0000 |
| Subject: | RE: [PHP] best way to get COUNT from result set | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31185@lists.php.net to get a copy of this message | ||
Hi,
> $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...
list($count)=mysql_fetch_row($rslt);
or, to cut the whole mess even shorter:
list($count)=mysql_fetch_row(mysql_query("SELECT count(id) FROM table"));
the last one does no error checking though..
Rgds,
Tfr
--==< tfr@cafe.ee >==< http://tfr.cafe.ee/ >==<
+372-50-17621 >==--