How to display the result of a search in mysql where returns more than 10mil result without crashing the browser?

Asked

Viewed 189 times

0

I am currently using the table jquery to display the results, but it takes a long time to display all the results and while the search is not finished the browser sometimes hangs. has some better way to show the results but without crashing the browser?

where ta $querypersonalized would be a "SELECT * FROM tb_clientes" where it would return to some 10mil results

            <!-- - Tabela usuario  começo  -->
        <div class="form" id="frmFiltro">

         <table class="table table-bordered table-hover" id="minhaTabela">
            <thead>
               <tr>
                  <th>id</th>
                  <th>nome</th>
                  <th>cpf</th>
                  <th>data nascimento</th>
                  <th>cidade</th>
                  <th>celular</th>
                  <th>telefone ok</th>
                  <th>tpcliente</th>
                  <th>stcliente</th>
                  <th>atendente</th>
              </tr>
          </thead>

          <tbody>

<?php

$result = $conexao->query($querypersonalizada);
              $qtd_reg_filtro = mysqli_num_rows($result); //quantidade de registro

               echo $qtd_reg_filtro." Registro(s) encontrado(s)!"; //mostra a quantidade de registro
               if($result){
                 while ($row = $result->fetch_array()){
                    ?>
                    <tr>
                      <?php echo '<td>'. $row['cli_id'].'</td>'; ?>
                      <?php echo '<td><a id="linkCliNome" href="viewcliente.php?id='.$row['cli_id'].'" target="_blank">'. $row['cli_nome'].'</a></td>'; ?>
                      <?php echo '<td>'. $row['cli_cpf'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_data_nascimento'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_cidade'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_celular'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_telefone_ok'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_tp_cliente'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_st_cliente'].'</td>'; ?>
                      <?php echo '<td>'. $row['cli_atendente'].'</td>'; ?>
                  </tr>


              <?php } 
              $result->free();
          } ?>

      </tbody>
  </table>

  <script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
  <script src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
  <script>
    $(document).ready(function() {
       $('#minhaTabela').DataTable({
          "language": {
             "lengthMenu": "Mostrando _MENU_ registros por página",
             "zeroRecords": "Nada encontrado",
             "info": "Mostrando página _PAGE_ de _PAGES_",
             "infoEmpty": "Nenhum registro disponível",
             "infoFiltered": "(filtrado de _MAX_ registros no total)"
         }
     });
   });
</script>

</div>
<!--  Tabela usuario  FIM  -->
  • Could you post the code? Without the code it is difficult to help you

  • I’ll put the code

  • Use jQuery’s Ajax to call the php function, so the ui won’t crash while the query is being made. This will not ensure that the browser does not slow down

  • I think I got it, I’m gonna try (Y)

No answers

Browser other questions tagged

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