Thanks to anyone who is willing to help. I am trying to run a sql SELECT in a fetch loop of another select loop.
$mysqli = connect();
$stmt= $mysqli->prepare('SELECT lobby_id, user_penName, lobby_str
FROM `tbl_lobbies`
JOIN tbl_users ON tbl_lobbies.user_id = tbl_users.user_id
WHERE lobby_active = ?');
$stmt->bind_param('i',$on);
$stmt->execute();
$stmt->bind_result($lid, $hostName, $str);
while($stmt->fetch()){
$users=0;
$on = 1;
//echo $lid;
$stmt2= $mysqli->prepare('SELECT `user_id` FROM `tbl_usersInLobbies` WHERE lobby_id = ?');
$stmt2->bind_param('i', $lid);
echo 1;
$stmt2->execute();
$stmt2->bind_result($users);
while($stmt2->fetch()){
echo 1;
$nou .= ' <i class="fa fa-square" aria-hidden="true"></i>';
}
$stmt2->close();
This code only works if I open another connection in the loop. I know that isnt effective so im trying to see if there is another way. I know there is no variable errors in the code. I would use another form of sql in there is no other option. PS im still a student so im sorry for any obvious answers.