note 95872 added to function.mysql-num-rows
| From: | MichelSchenk at osu1 dot php dot net | Date: | Tue, 26 Jan 2010 22:28:27 +0000 |
| Subject: | note 95872 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165340@lists.php.net to get a copy of this message | ||
A little combination of previous solutions, I only needed to know how many rows and I have to limit
a sorted list:
<?PHP
//connect to dbase
$qry = "SELECT SQL_CALC_FOUND_ROWS '0' FROM $table LIMIT 0 UNION SELECT
FOUND_ROWS()";
$result=mysql_query($qry) or die(mysql_error());
while ($row = mysql_fetch_row($result)) $total_rows = $row[0];
?>
After this code you can do SELECT ... FROM ... ORDER BY ... LIMIT ...
I've tried to do this in one query with UNION like:
(SELECT SQL_CALC_FOUND_ROWS '0'... FROM ... ORDER BY ... LIMIT ...) UNION (SELECT
FOUND_ROWS() ...)
This didn't work :-( maybe somebody can solve this?
----
Server IP: 69.147.83.197
Probable Submitter: 81.206.94.66
----
Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php
Edit -- https://master.php.net/note/edit/95872
Del: integrated -- https://master.php.net/note/delete/95872/integrated
Del: useless -- https://master.php.net/note/delete/95872/useless
Del: bad code -- https://master.php.net/note/delete/95872/bad+code
Del: spam -- https://master.php.net/note/delete/95872/spam
Del: non-english -- https://master.php.net/note/delete/95872/non-english
Del: in docs -- https://master.php.net/note/delete/95872/in+docs
Del: other reasons-- https://master.php.net/note/delete/95872
Reject -- https://master.php.net/note/reject/95872
Search -- https://master.php.net/manage/user-notes.php