note 95329 added to function.mysql-num-rows
| From: | ben-at-telkoth-dot-net at osu1 dot php dot net | Date: | Sun, 27 Dec 2009 20:42:28 +0000 |
| Subject: | note 95329 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164366@lists.php.net to get a copy of this message | ||
lucky8919: MySQL can count things up for you if you ask it to. you'll consume less resources
than fetching every row that way, too:
$command = 'SELECT COUNT(idnum) AS num_users FROM users WHERE class=2';
$result = mysql_query($command);
$data = mysql_fetch_assoc($result); // fetch result
$count = $data['num_users'];
----
Server IP: 69.147.83.197
Probable Submitter: 71.53.206.84
----
Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php
Edit -- https://master.php.net/note/edit/95329
Del: integrated -- https://master.php.net/note/delete/95329/integrated
Del: useless -- https://master.php.net/note/delete/95329/useless
Del: bad code -- https://master.php.net/note/delete/95329/bad+code
Del: spam -- https://master.php.net/note/delete/95329/spam
Del: non-english -- https://master.php.net/note/delete/95329/non-english
Del: in docs -- https://master.php.net/note/delete/95329/in+docs
Del: other reasons-- https://master.php.net/note/delete/95329
Reject -- https://master.php.net/note/reject/95329
Search -- https://master.php.net/manage/user-notes.php