Guest User

Untitled

a guest
Jan 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. <?php
  2. include('config/db_connect.php');
  3.  
  4. $sql = "SELECT * FROM articulos";
  5.  
  6. $result = $conn->query($sql);
  7. $reg = $result->num_rows;
  8. $conn->close();
  9. ?>
  10.  
  11. <div style="text-align:center;">
  12. Número Total de Productos Registrados: <font color="green" style="font:bold 22px 'Aleo';"><?php echo $reg;?></font></div>
  13.  
  14. <br>
  15.  
  16. <?php
  17. echo '<div id="Layer1" style="width:50; height:50; overflow: scroll;">';
  18. include ('config/db_connect.php');
  19.  
  20. /** PAGINATION CODE **/
  21.  
  22. $pagina_actual = isset($_GET['pagina_entrada']) ? $_GET['pagina_entrada'] : 1;
  23.  
  24. $por_pagina = 5;
  25. $total_paginas = /* esta variable la calculaste tu */
  26. ceil($reg / $por_pagina);
  27.  
  28.  
  29. $limit = $por_pagina;
  30. $offset = $por_pagina * max($pagina_actual-1, 0);
  31.  
  32.  
  33. $sql = "SELECT * FROM articulos
  34. ORDER BY id ASC ";
  35.  
  36. /** PAGINATION CODE **/
  37. $sql .= "LIMIT $limit OFFSET $offset";
  38. /** PAGINATION CODE **/
  39.  
  40. $result = $conn->query($sql);
  41. if ($result->num_rows > 0) {
  42. print '<table cellpadding="2" cellspacing="2" border="5" class="datatable-1 table table-bordered table-striped display" width="100%">
  43. <thead>
  44. <tr>
  45. <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>
  46. </thead><tbody>';
  47. while($row = $result->fetch_assoc()) {
  48. print '<tr class="odd gradeX">
  49. <td>
  50. '.$row['nombre_articulo'].'
  51. </td>
  52. <td>
  53. '.$row['precio_compra'].'
  54. </td>
  55. <td class="center">
  56. '.$row['precio_venta'].'
  57. </td>
  58. <td class="center">
  59. '.$row['ganancia'].'
  60. </td>
  61. <td>
  62. '.$row['cantidad'].'
  63. </td>
  64.  
  65. <td>
  66. '.$row['proveedor'].'
  67. </td>
  68. <td>
  69. '.$row['fecha_creado'].'
  70. </td>
  71. <td>
  72. '.$row['fecha_actualizacion'].'
  73. </td>
  74. <td>
  75. '.$row['actualizado_por'].'
  76. </td>
  77. <td>
  78. <div class="controls">
  79. <div class="dropdown">
  80. <a class="dropdown-toggle btn" data-toggle="dropdown" href="#">OPCION <i class="fa fa-gears"></i></a>
  81. <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
  82. <li><a href="config/edi_articulo.php?ref='.$row['id'].'"><i class="fa fa-edit"></i> EDITAR</a></li>
  83. <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>
  84.  
  85. </ul>
  86. </th>
  87.  
  88. </tr>';
  89. }}
  90. else {
  91. print '<div class="module-body">
  92. <div class="alert alert-success">
  93. <button type="button" class="close" data-dismiss="alert">×</button>
  94. <h3>NO SE ENCONTRARON ARTICULOS REGISTRADOS!</h3>
  95. Todos Los Artiulos Registrados Se Muestran Aqui.</div></div>';}
  96.  
  97. print ' </tbody></table>';
  98.  
  99. echo "</div>";
  100.  
  101. $conn->close();?>
  102. <?php /*
  103. Por propositos de simplicidad, NO Tocaremos numeros de páginas
  104. Sólo siguiente y anterior
  105. */ ?>
  106. <br>
  107. <div class="text-center">
  108. <?php /* si no es la primera página (2 en adelante) */ ?>
  109. <?php if($pagina_actual > 1): ?>
  110. <a class="btn btn-default" href="?pagina_entrada=<?php echo $pagina_actual-1 ?>">
  111. &laquo; Página Anterior
  112. </a>
  113. <?php endif ?>
  114.  
  115. <?php /* si no es la ultima página (ultima-1 hacia atrás) */ ?>
  116. <?php if($pagina_actual < $total_paginas): ?>
  117. <a class="btn btn-default" href="?pagina_entrada=<?php echo $pagina_actual+1 ?>">
  118. Página Siguiente &raquo;
  119. </a>
  120. <?php endif ?>
  121. </div>
Add Comment
Please, Sign In to add comment