note 117161 added to mysqli-result.fetch-assoc
| From: | HeshamMohamedSediek | Date: | Fri, 24 Apr 2015 02:02:47 +0000 |
| Subject: | note 117161 added to mysqli-result.fetch-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202357@lists.php.net to get a copy of this message | ||
when you fetch the data from the query variable
and try to fetch it again in another part of the script
from the same query variable ,
when you try to echo all data you have fetched,
it will not echo the data you have used in the first fetch
(it will exceed the results you have used in the first fetch).......
Example :
<?php
$connect = new mysqli("localhost","root","root","elshamy")
or die (mysqli_error());
$query=$connect->query("SELECT * FROM users ORDER BY id ASC");
$first_fetch=$query->fetch_array(MYSQLI_ASSOC);
echo
$first_fetch['id']."===>".$first_fetch['user_name']."\n--------------------\n";
while($row=$query->fetch_array(MYSQLI_ASSOC)){
/*it will exceed the first
id&user_name value that
you have use in the first fetch*/
echo $row['id']." ".$row['user_name']."<br/>";
}
?>
above example will echo :
1===>userA
------------------------
2===>userB
3===>userC
4===>userD
----
Server IP: 72.52.91.14
Probable Submitter: 197.32.25.30
----
Manual Page -- http://php.net/manual/en/mysqli-result.fetch-assoc.php
Edit -- https://master.php.net/note/edit/117161
Del: integrated -- https://master.php.net/note/delete/117161/integrated
Del: useless -- https://master.php.net/note/delete/117161/useless
Del: bad code -- https://master.php.net/note/delete/117161/bad+code
Del: spam -- https://master.php.net/note/delete/117161/spam
Del: non-english -- https://master.php.net/note/delete/117161/non-english
Del: in docs -- https://master.php.net/note/delete/117161/in+docs
Del: other reasons-- https://master.php.net/note/delete/117161
Reject -- https://master.php.net/note/reject/117161
Search -- https://master.php.net/manage/user-notes.php