Good, I have a list of a database with the controller view model and I do not know how to paginate it
view_listUsers
<div id="cuadro">
<div id="titulo">
<h1>Registros</h1>
</div>
</div>
<table>
<thead>
<tr class="centro">
<td>Usuario</td>
<td>Contraseña</td>
<td>Nombre</td>
<td>1º Apellido</td>
<td>2º Apellido</td>
<td>DNI</td>
<td>Dirección</td>
<td>Población</td>
<td>Código Postal</td>
<td>Provincia</td>
<td>Teléfono</td>
<td>Email</td>
<td>Web</td>
<td>Blog</td>
<td>Twitter</td>
<td>Fecha de registro</td>
</tr>
<tbody>
<?php foreach ($usuarios as $user)
{
?>
<tr>
<td><?php echo $user['usuario'];?></td>
<td><?php echo $user['contraseña'];?></td>
<td><?php echo $user['nombre'];?></td>
<td><?php echo $user['apellido1'];?></td>
<td><?php echo $user['apellido2'];?></td>
<td><?php echo $user['dni'];?></td>
<td><?php echo $user['direccion'];?></td>
<td><?php echo $user['poblacion'];?></td>
<td><?php echo $user['CPostal'];?></td>
<td><?php echo $user['provincia'];?></td>
<td><?php echo $user['telefono'];?></td>
<td><?php echo $user['email'];?></td>
<td><?php echo $user['web'];?></td>
<td><?php echo $user['blog'];?></td>
<td><?php echo $user['twitter'];?></td>
<td><?php echo $user['fecha'];?></td>
</tr>
<?php }?>
</tbody>
</table>
ctrl_listUsers
include_once (MODEL_PATH.'model_usuario.php');
$usuarios = listaUsuarios();
include (VIEW_PATH.'view_listarUsuarios.php');
model_user
include_once (MODEL_PATH.'claseBD.php');
function insertaUsuario($valores){
try{
$sentencia = 'INSERT INTO usuarios (usuario, contraseña, nombre, apellido1, apellido2, dni,direccion, '
. 'poblacion, CPostal, provincia,telefono, email, web, blog, twitter)'
. ' VALUES ("'.$valores['usuario'].'","'.$valores['pass'].'","'.$valores['nombre'].'","'.$valores['apellido1'].'","'.$valores['apellido2'].'",'
. '"'.$valores['dni'].'","'.$valores['direccion'].'","'.$valores['poblacion'].'","'.$valores['CPostal'].'","'.$valores['provincia'].'","'.$valores['telefono'].'",'
. '"'.$valores['email'].'","'.$valores['web'].'","'.$valores['blog'].'","'.$valores['twitter'].'","'.$valores['tipo'].'")';
$Db=db::getInstance();
$Db->Ejecutar($sentencia);
} catch (PDOexception $e){
die($e->getMessage());
}
}
function listaUsuarios(){
try{
$sentencia='SELECT * FROM usuarios ORDER BY fecha DESC';
$Db=db::getInstance();
$listado=$Db->Ejecutar($sentencia);
return $listado;
} catch (PDOexception $e){
die($e->getMessage());
}
}
function borraUsuario($usuario){
try{
$sentencia = 'DELETE FROM usuarios WHERE usuario =".$usuario."';
$Db=db::getInstance();
$listado=$Db->Ejecutar($sentencia);
} catch (PDOexception $e) {
die($e->getMessage());
}
}