How to decrease the query time to my BD to give options to my multiselect

0

It turns out that I have the following code:

<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="css/bootstrap-3.3.2.min.css" type="text/css"/>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap-3.3.2.min.js"></script>

<!-- Include the plugin's CSS and JS: -->
<script type="text/javascript" src="js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css"/>
</head>
<script>
  $(document).ready(function(){
  $('#sites_dependientes_2').multiselect({
   nonSelectedText: 'Selecciona opcion',
   enableFiltering: true,
   enableCaseInsensitiveFiltering: true,
   buttonWidth:'200px',
   maxHeight: '200',
     });
  });
  </script>
 <body>
 <form method="post" id="framework_form3">
              <div class="form-group" >
                <div class="col-sm-1" ">
                   <select id="sites_dependientes_2" name="sites_dependientes_2[]" multiple >
                         <?php

          $conn=mysqli_connect("localhost","root","","mantenimiento") ;
                                  if ($conn)echo "conexion ok" ;
                                 else echo "conexion ko";
                                 $state = $_POST['framework'];
                                 $consulta="select * from direccion ";
                                 $resultado=mysqli_query($conn,$consulta);
                                 $sumax=1;      

     while($lista=mysqli_fetch_array($resultado)){

                          ?> 
                                       <option id="<?php echo "man_".$sumax; ?>" value="<?php echo $sumax; ?>">  <?php echo $lista['id_celda']."/".$lista['nombre_site']; ?></option> 
                          <?php $sumax++; } ?>
                    </select>
                    </div>
                </div>
            </form>
    </body>
   </html>

It turns out that I am consulting my database, to give values to my options, and so it can be used to perform the multiselect. But it turns out that in my "address" table I have approx. 5000 register, and the search is done in a little more than 10 seconds, as I would do to load fast when loading the page and so that I do not necessarily show all the options (at this point I think there is a code that can be added to the javascript, but I did not find which one)

    
asked by Kevincs7 15.12.2018 в 06:57
source

0 answers