i get some data from mysql.
$result = $forum_model->get_info($_SESSION['group_id']);
// step 1
while($user = mysqli_fetch_assoc($result))
{
some code
}
but when i later some lines beneath want to use the same data pulled out from mysql it doesnt work.
// step 2
while($user = mysqli_fetch_assoc($result))
{
some code
}
is the $result emptied? do i have to make another
$result = $forum_model->get_info($_SESSION['group_id']);
to get the same data?
i have tried to do like this in the start
$result = $forum_model->get_info($_SESSION['group_id']);
$result2 = $result;
then in the second step use $result2 instead but it doesnt seem to work either.
how can i solve this easily?
Yes, this code
iterates through the statement, moving the result pointer until it reaches the end of the result set.
In order to rerun your query (not sure why you can’t store the results in a php array), you must do the following: