note 104630 added to mysqli-result.num-rows
| From: | randomsort at gmail dot com | Date: | Mon, 27 Jun 2011 08:39:21 +0000 |
| Subject: | note 104630 added to mysqli-result.num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180978@lists.php.net to get a copy of this message | ||
This may be a bug or a feature, but I do see peculiar behaviour with regards to this feature on php
version 5.2.6-1+lenny10. Also bugs.php.net is down.
The value in mysqli-result->num_rows is not the total number of rows, but rather the number of
rows you have iterated over so far.
<?php
$sql = "valid select statement that yields results";
if($result = mysqli-connection->query($sql, MYSQLI_USE_RESULT))
{
echo $result->num_rows; //zero
while($row = $result->fetch_row())
{
echo $result->num_rows; //incrementing by one each time
}
echo $result->num_rows; // Finally the total count
}
?>
This has had me confused more than a few times,
I hope I can save you some of that trouble.
Regards,
Johan Abildskov
----
Server IP: 69.147.83.197
Probable Submitter: 90.185.25.178
----
Manual Page -- http://www.php.net/manual/en/mysqli-result.num-rows.php
Edit -- https://master.php.net/note/edit/104630
Del: integrated -- https://master.php.net/note/delete/104630/integrated
Del: useless -- https://master.php.net/note/delete/104630/useless
Del: bad code -- https://master.php.net/note/delete/104630/bad+code
Del: spam -- https://master.php.net/note/delete/104630/spam
Del: non-english -- https://master.php.net/note/delete/104630/non-english
Del: in docs -- https://master.php.net/note/delete/104630/in+docs
Del: other reasons-- https://master.php.net/note/delete/104630
Reject -- https://master.php.net/note/reject/104630
Search -- https://master.php.net/manage/user-notes.php