Web slows down due to table with thousands of records

0

Good afternoon, I find myself doing a library with PHP, MySQL and JS for a family member. When he asked me, he told me that he did not want to see the results paged, but all on the same page. The problem comes when I load thousands of records in a table , since the functions of Javascript are slowed down, like one dedicated to dragging columns through th, making the application very unusable. Any advice or something to solve this problem?

The code of this function is obtained from here: link

Here is the PHP code that fills the table.

<?php
//Se realiza un include con el script necesario para la conexión a la  BBDD y las funciones
include "../funciones.php";
include "../conexion.php";
//Consulta SQL necesaria para la información a a mostrar
$sql = "SELECT libros.nref, libros.portada, libros.titulo,libros.isbn,libros.edicion,libros.encuadernacion,libros.coleccion,libros.idioma,libros.puntuacion,libros.comentario,libros.leido,libros.precio,DATE_FORMAT(libros.anyocompra, '%d-%m-%Y') as fechacompra,DATE_FORMAT(libros.fechapublicacion, '%d-%m-%Y') as fechapublicacion,libros.fechaintroduccion, autores.anombre, editoriales.enombre, g.gnombre,sg.gnombre as subgenero, localizaciones.lnombre, lugarcompra.lcnombre from libros
          left JOIN autores on libros.autor = autores.aid 
          left JOIN editoriales on libros.editorial = editoriales.eid
          left JOIN generos as g on libros.genero = g.gid 
          left JOIN generos as sg on libros.subgenero = sg.gid 
          left JOIN localizaciones on libros.localizacion = localizaciones.lid
          left JOIN lugarcompra on libros.lugarcompra = lugarcompra.lcid order by nref asc";
$resultado = $con->query($sql);
if ($resultado->num_rows == 0){
  echo "<script>";
    echo "alert('La tabla se encuentra vacía')";
  echo "</script>";
    exit;
}
while ($fila = $resultado->fetch_assoc()) {

  echo "<tr>";
    echo "<td><a href='fichalibros.php?nref=$fila[nref]'>".$fila["nref"]."</td></a>
    <td>".$fila["titulo"]."</td>
    <td>".$fila["isbn"]."</td>
    <td>".$fila["anombre"]."</td>
    <td>".$fila["enombre"]."</td>
    <td>".$fila["gnombre"]."</td>
    <td>".$fila["subgenero"]."</td>
    <td>".$fila["edicion"]."</td>
    <td>".$fila["lnombre"]."</td>
    <td>".$fila["encuadernacion"]."</td>
    <td>".$fila["coleccion"]."</td>
    <td>".$fila["idioma"]."</td>
    <td>".$fila["puntuacion"]."</td>
    <td>".$fila["leido"]."</td>
    <td>".$fila["precio"]."</td>
    <td>".$fila["lcnombre"]."</td>
    <td>".$fila["fechacompra"]."</td>
    <td>".$fila["fechapublicacion"]."</td>
    <td><form method=post action='../delete.php'><button class='btn btn-danger' type='Submit' name='borrado' value='$fila[nref]''>Borrar</button><input type='hidden' name='tabla' value='libros'></td></form>
    <td><form method='post' action='updatelibros.php'><button class='btn btn-primary' type='Submit' name='update' value='$fila[nref]'>Actualizar</button></form></td>";
  echo "</tr>";
}
echo "<tbody></table>";
// Liberar resultados
$resultado->free();
// Cerrar la conexión
$con->close();

Thanks in advance.

    
asked by Mario 16.10.2017 в 18:13
source

0 answers