I want to display messages in my chatbox but my code displays only first row from database. I hope polish names of variables arent problem. Greets.
Chatbox:
phpmyadmin rows:
<?php
//connecting to database
$connect = @mysqli_connect("localhost","root","","chat") or die ('nie udalo sie polaczyc do bazy danych');
//fetch messages
$zapytanie = mysqli_query($connect, "SELECT * FROM wiadomosci");
$wynik_zapytania = mysqli_fetch_array($zapytanie);
;
foreach ($zapytanie as $key) {
$nazwa = $wynik_zapytania['nazwa'];
$tresc = $wynik_zapytania['tresc'];
$godzina = $wynik_zapytania['godzina'];
echo("
<li>
<div class='chat-body clearfix'>
<div class='header'>
<small class='text-muted'><span class='glyphicon glyphicon-time'></span>".$godzina."</small>
<strong class='pull-right primary-font'>".$nazwa."</strong>
</div>
<div class='tresc'>
<p>
".$tresc."
</p>
</div>
</div>
</li>
");
}
?>
It working. I tested this on my XAMPP server.