Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('config/db_connect.php');
- $sql = "SELECT * FROM articulos";
- $result = $conn->query($sql);
- $reg = $result->num_rows;
- $conn->close();
- ?>
- <div style="text-align:center;">
- Número Total de Productos Registrados: <font color="green" style="font:bold 22px 'Aleo';"><?php echo $reg;?></font></div>
- <br>
- <?php
- echo '<div id="Layer1" style="width:50; height:50; overflow: scroll;">';
- include ('config/db_connect.php');
- /** PAGINATION CODE **/
- $pagina_actual = isset($_GET['pagina_entrada']) ? $_GET['pagina_entrada'] : 1;
- $por_pagina = 5;
- $total_paginas = /* esta variable la calculaste tu */
- ceil($reg / $por_pagina);
- $limit = $por_pagina;
- $offset = $por_pagina * max($pagina_actual-1, 0);
- $sql = "SELECT * FROM articulos
- ORDER BY id ASC ";
- /** PAGINATION CODE **/
- $sql .= "LIMIT $limit OFFSET $offset";
- /** PAGINATION CODE **/
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- print '<table cellpadding="2" cellspacing="2" border="5" class="datatable-1 table table-bordered table-striped display" width="100%">
- <thead>
- <tr>
- <th>NOMBRE ARTICULO</th><th>PRECIO DE COMPRA</th><th>PRECIO DE VENTA</th><th>GANANCIA</th><th>CANTIDAD</th><th>PROVEEDOR</th><th>FECHA DE REGISTRO</th><th>FECHA ACTUALIZACION</th><th>ACTUALIZADO POR<th>ACCION</th></tr>
- </thead><tbody>';
- while($row = $result->fetch_assoc()) {
- print '<tr class="odd gradeX">
- <td>
- '.$row['nombre_articulo'].'
- </td>
- <td>
- '.$row['precio_compra'].'
- </td>
- <td class="center">
- '.$row['precio_venta'].'
- </td>
- <td class="center">
- '.$row['ganancia'].'
- </td>
- <td>
- '.$row['cantidad'].'
- </td>
- <td>
- '.$row['proveedor'].'
- </td>
- <td>
- '.$row['fecha_creado'].'
- </td>
- <td>
- '.$row['fecha_actualizacion'].'
- </td>
- <td>
- '.$row['actualizado_por'].'
- </td>
- <td>
- <div class="controls">
- <div class="dropdown">
- <a class="dropdown-toggle btn" data-toggle="dropdown" href="#">OPCION <i class="fa fa-gears"></i></a>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
- <li><a href="config/edi_articulo.php?ref='.$row['id'].'"><i class="fa fa-edit"></i> EDITAR</a></li>
- <li><a '; ?> onclick="return confirm('Estas seguro de borrar el articulo <?php echo $row['nombre_articulo']; ?> ?')" <?php print 'href="config/borrar_articulos.php?ref='.$row['id'].'"><i class="fa fa-trash"></i> BORRAR</a></li></ul></div></div></div></td>
- </ul>
- </th>
- </tr>';
- }}
- else {
- print '<div class="module-body">
- <div class="alert alert-success">
- <button type="button" class="close" data-dismiss="alert">×</button>
- <h3>NO SE ENCONTRARON ARTICULOS REGISTRADOS!</h3>
- Todos Los Artiulos Registrados Se Muestran Aqui.</div></div>';}
- print ' </tbody></table>';
- echo "</div>";
- $conn->close();?>
- <?php /*
- Por propositos de simplicidad, NO Tocaremos numeros de páginas
- Sólo siguiente y anterior
- */ ?>
- <br>
- <div class="text-center">
- <?php /* si no es la primera página (2 en adelante) */ ?>
- <?php if($pagina_actual > 1): ?>
- <a class="btn btn-default" href="?pagina_entrada=<?php echo $pagina_actual-1 ?>">
- « Página Anterior
- </a>
- <?php endif ?>
- <?php /* si no es la ultima página (ultima-1 hacia atrás) */ ?>
- <?php if($pagina_actual < $total_paginas): ?>
- <a class="btn btn-default" href="?pagina_entrada=<?php echo $pagina_actual+1 ?>">
- Página Siguiente »
- </a>
- <?php endif ?>
- </div>
Add Comment
Please, Sign In to add comment