Re: anybody knows this error?
| From: | Erik Price | Date: | Thu, 20 Jun 2002 13:38:23 +0000 |
| Subject: | Re: anybody knows this error? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103120@lists.php.net to get a copy of this message | ||
On Thursday, June 20, 2002, at 08:39 AM, W. Enserink wrote:
I am quering my db. Since I want to know how many records I got back I use $count=count($result_array);You can save yourself a ton of resources and just do this from within the database itself, using COUNT() function. In MySQL: // $db = database connection info $query = 'SELECT COUNT(*) AS count FROM tablename'; $result = mysql_query($query, $db); $count = mysql_result($result, 0); Now $count is equal to the number of rows in the table. You can further qualify this with a WHERE clause in the SQL query that cuts down the number of results, to your liking. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com