Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. case 'recebeMsg';
  2.                     $tempo_page = (isset($_SESSION['time_chat'])== true) ? $_SESSION['time_chat'] : date("Y-m-d H:i:s");
  3.                     $seleciona_msg = mysqli_query($conexao, "SELECT * from chat WHERE id_user != '$id' and id_lobby = '$id_lobby' and timestamp >= '$tempo_page' ORDER BY id ASC");
  4.                     if(mysqli_num_rows($seleciona_msg) > 0){
  5.                         $_SESSION['time_chat'] = date("Y-m-d H:i:s");
  6.                         $msgs = array('status' => 'success', 'msgs'=>mysqli_num_rows($seleciona_msg) );
  7.                         while($dados = mysqli_fetch_array($seleciona_msg)){
  8.                             $render = array(
  9.                                 'id_user'=>$dados['id_user'],
  10.                                 'contente'=>$dados['content'],
  11.                                 'time'=>$dados['time'],
  12.                                 'nick'=>$dados['nick']);
  13.                                 array_push($msgs, $render);
  14.                         }
  15.                         echo json_encode($msgs, JSON_PRETTY_PRINT);
  16.  
  17.                     }else{
  18.                         echo Erro('notnew');
  19.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement