Paging with Jquery PHP Mysql in MVC template

Asked

Viewed 299 times

0

Well I have a little problem, I have a table with the conversations of a system internal chat that was created here in the company. My task will be to paginate the history generated with the buttons "Previous" and "Next" limiting the number of messages sent. I have the code of the html, javascript and php(controller) I hope that if you can’t help me completely some light would be enough for my walk!

The code in html:

<div class="row mtop10" style="height:95% !important; margin-bottom: -30px;">
   <div class="col-xs-12 historico_chat" id="historico_chat">

   </div>
</div>
<center>
    <button id="anterior" class="anterior">&lt;&lt; Anterior</button>&nbsp;&nbsp;&nbsp;
    <span id="numeracao"></span>&nbsp;&nbsp;&nbsp;
    <button id="proximo" class="proximo">Próximo &gt;&gt;</button>
</center>

The code in PHP:

public function ajaxcarregaHistoricochat(){

 $obj_chat        = new daoChat();
 $chat            = $obj_chat->Where(" (iat_destinatario = '".$_POST['ifu']."' AND iat_remetente = '".$_POST['remetente']."') OR (iat_destinatario = '".$_POST['remetente']."' AND iat_remetente = '".$_POST['ifu']."') ")->Limite(1, 10)->Recursiva()->Consultar();

 $html  ="";
 $html .="<div>";
      foreach ($chat as $ch){
          $html .="<p style='color: blue; font-weight: bold; text-align:left;'>".$ch['iat_destinatario']."</p>";
          $html .="<p style='color: red;text-align:left;'>".$ch['iat_mensagem']."</p>";
      }

    $html .="</div>";

    echo $html;
}

And the code in JS:

$("body").on("click",".abre_historico",function(){
    $(".modal_historico").css("z-index","999");
    modal.style.display = "block";
    var remetente = $("#chat_remetente").val();
    var ifu       = $(this).data("ifu");
    //alert(ifu);
    $.post(""+url+"insoft/header/ajaxcarregaHistoricochat",{remetente:remetente,ifu:ifu},function(data){
        $("#historico_chat").html(data);
    });
});
  • Thank you @Kennyrafael :D

  • I forgot but "#chat_sender" is where you get the value of the sender of the conversation , "abre_historico" is the button that opens the modal box where the history is loaded and "var ifu = $(this). data("ifu");" is the variable that receives the value of the date-ifu that would be the recipient via the controller in php.

  • I can load the relevant messages to the logged-in sender and their addressee and limit them through the limit function seen in the php code above, but the rest I can’t load.

  • What would be the difficulty you are facing?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.