Next element of array every iteration chat messages display php -


i want display messages in chatbox code displays first row database. hope polish names of variables arent problem. greets.

chatbox:

phpmyadmin rows:

<?php   //connecting database $connect = @mysqli_connect("localhost","root","","chat") or die ('nie udalo sie polaczyc bazy danych');  //fetch messages  $zapytanie = mysqli_query($connect, "select * wiadomosci");  $wynik_zapytania = mysqli_fetch_array($zapytanie); ; foreach ($zapytanie $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>         "); }  ?> 

<?php require_once "connect.php";  $zapytanie = mysqli_query($link, "select id, nazwa, tresc, godzina wiadomosci");         while ($row = mysqli_fetch_array($zapytanie)) {     $zapytanie_tablica[] = array('id'=>$row['id'], 'imie'=> $row['nazwa'], 'tekst'=> $row['tresc'], 'czas'=> $row['godzina']); }         ; ?> <?php foreach($zapytanie_tablica $key): ?>                                    <li>                                 <div class='chat-body clearfix'>                                     <div class='header'>                                         <small class='text-muted'><span class='glyphicon glyphicon-time'></span></small>                                         <strong class='pull-right primary-font'><?php  echo htmlspecialchars($key['imie'], ent_quotes, 'utf-8'); ?></strong>                                     </div>                                     <div class='tresc'>                                     <p>                                         <?php  echo htmlspecialchars($key['tekst'], ent_quotes, 'utf-8'); ?>                                     </p>                                  </div>                                 </div>                             </li>  <?php endforeach; ?> 

it working. tested on xampp server.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -