Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. <?php
  2.  
  3. $db_host = "localhost";
  4. $db_user = "root";
  5. $db_pass = "";
  6. $db_name = "mva_colegio";
  7.  
  8. $conectahugo = new mysqli($db_host, $db_user, $db_pass, $db_name);
  9.  
  10.  
  11.  
  12. $sql = "SELECT * FROM mva_servicios WHERE estado_p = 1 ORDER BY id_prod DESC;";
  13. $resultado = mysqli_query($conectahugo, $sql);
  14.  
  15. //si no hay reultado imprimimos que diga error
  16. if (!$resultado) {
  17. die('Error no hay datos');
  18. }else{
  19. while ($data = mysqli_fetch_assoc($resultado)) {
  20. $arreglo["data"][]= $data;
  21. }
  22. //pasamos los datos json
  23. echo json_encode($arreglo);
  24. }
  25.  
  26. mysqli_free_result($resultado);
  27.  
  28.  
  29. mysqli_close($conectahugo);
  30.  
  31.  
  32.  
  33.  
  34.  
  35. ?>
  36.  
  37. <table id="dataalumnos" class="table table-hover">
  38. <thead bgcolor="#eeeeee" align="center">
  39. <tr>
  40.  
  41. <th>Carné</th>
  42. <th>Alumno </th>
  43. <th>Dirección </th>
  44. <th>Tel</th>
  45. <th>Encargado </th>
  46. <th>Registrado</th>
  47. <th class="text-center"> Acciones </th>
  48.  
  49. </tr>
  50.  
  51. </thead>
  52.  
  53.  
  54. </table>
  55.  
  56.  
  57.  
  58. </div>
  59.  
  60.  
  61.  
  62. </div>
  63. </div>
  64.  
  65. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  66. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  67. <!-- Include all compiled plugins (below), or include individual files as needed -->
  68. <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
  69. <script src="datatables/js/jquery.dataTables.min.js"></script>
  70. <script src="datatables/js/dataTables.bootstrap.min.js"></script>
  71.  
  72. <script>
  73.  
  74.  
  75. var listar = function(){
  76. var table = $("#dataalumnos").DataTable({
  77.  
  78. "ajax":{
  79. "method":"POST",
  80. "url":"listar_servicios.php"
  81. },
  82. "columns":[
  83. {"data":"id_prod"},
  84. {"data":"descripcion_p"},
  85. {"data":"tipo_p"},
  86. {"data":"precio_p"},
  87. {"data":"estado_p"}
  88. ]
  89. });
  90. }
  91.  
  92.  
  93. </script>
  94.  
  95.  
  96.  
  97. <script>
  98. $(document).ready(function(){
  99. listar();
  100. $('#dataalumnos').DataTable({
  101. language: {
  102. "sProcessing": "Procesando...",
  103. "sLengthMenu": "Mostrar _MENU_ registros",
  104. "sZeroRecords": "No se encontraron resultados",
  105. "sEmptyTable": "Ningún dato disponible en esta tabla",
  106. "sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
  107. "sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
  108. "sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
  109. "sInfoPostFix": "",
  110. "sSearch": "Buscar:",
  111. "sUrl": "",
  112. "sInfoThousands": ",",
  113. "sLoadingRecords": "Cargando...",
  114. "oPaginate": {
  115. "sFirst": "Primero",
  116. "sLast": "Último",
  117. "sNext": "Siguiente",
  118. "sPrevious": "Anterior"
  119. },
  120. "oAria": {
  121. "sSortAscending": ": Activar para ordenar la columna de manera ascendente",
  122. "sSortDescending": ": Activar para ordenar la columna de manera descendente"
  123. }
  124. }
  125. });
  126.  
  127. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement