since yesterday, I have the problem that fetch_assoc() is just getting executed once and after that, every time I'm calling fetch_assoc(), the returned value is null.
Can someone figure out what's the problem? If I do the query in phpmyadmin, the expected results aren't null.
$sent = $mysqli_chat->query("SELECT to_user_id FROM chat WHERE from_user_id='" . $_SESSION['id'] . "';");
$receive = $mysqli_chat->query("SELECT from_user_id FROM chat WHERE to_user_id='" . $_SESSION['id'] . "';");
while ($row = $receive->fetch_assoc()){
$contacts = $mysqli->query('SELECT vorname_eltern, nachname_eltern, vorname_lehrer, nachname_lehrer FROM login WHERE id="' . $row['from_user_id'] . '";');
$nachname = $contacts->fetch_assoc()['nachname_eltern'] . $contacts->fetch_assoc()['nachname_lehrer'];
$vorname = $contacts->fetch_assoc()['vorname_eltern'] . $contacts->fetch_assoc()['vorname_lehrer'];
$chats .= '<li class="list-group-item p-0 px-3 pb-2" style="border-top:0;" onclick="changeChat(' . $i++ . ')">
<img class="user-avatar rounded-circle mr-2" src="images/avatars/0.jpg" alt="User Avatar" width="40" height="40"><span>' . $vorname . ' ' . $nachname . '</span>
</li>';
$js_nachname .= "'" . $nachname . "', ";
$js_vorname .= "'" . $vorname . "', ";
}