note 18191 added to function.mysql-num-rows
| From: | tac at smokescreen dot org | Date: | Mon, 14 Jan 2002 04:58:30 +0000 |
| Subject: | note 18191 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-24787@lists.php.net to get a copy of this message | ||
MySQL 4.0 supports a fabulous new feature that allows you to get the number of rows that would have
been returned if the query did not have a LIMIT clause. To use it, you need to add
SQL_CALC_FOUND_ROWS to the query, e.g.
$sql = "Select SQL_CALC_FOUND_ROWS * from table where state='CA' limit 50";
$result = mysql_query($sql);
$sql = "Select FOUND_ROWS()";
$count_result = mysql_query($sql);
You now have the total number of rows in table that match the criteria. This is great for knowing
the total number of records when browsing through a list.
--
http://www.php.net/manual/en/function.mysql-num-rows.php
http://master.php.net/manage/user-notes.php?action=edit+18191
http://master.php.net/manage/user-notes.php?action=delete+18191
http://master.php.net/manage/user-notes.php?action=reject+18191