Re: determining number of rows in a mysql table

From: Date: Wed, 31 Mar 2004 16:51:30 +0000
Subject: Re: determining number of rows in a mysql table
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-181957@lists.php.net to get a copy of this message
From: "Richard Davey" <rich@launchcode.co.uk> > AB> $rows=mysql_query("select count(*) as count from users"); > AB> $count=mysql_fetch_array($rows); > > There's no need to extract the result into an array in this instance, > why bother giving PHP that extra overhead? Unless the query failed, > the value count will *always* exist at row 0, so you can simply do: > > $count = mysql_result($rows, 0, 'count'); Or even just $count = mysql_result($rows,0); ;) ---John Holmes...

« previous php.general (#181957) next »