Advertisement
yagami07

mostrartodo

Feb 25th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
  5. <link rel="stylesheet" type="text/css" href="../css/datatables.css">
  6. <link rel="stylesheet" type="text/css" href="../css/sweetalert2.css">
  7.  
  8. <script type="text/javascript" src="../js/jquery.js"></script>
  9. <script type="text/javascript" src="../js/datatables.js"></script>
  10. <script type="text/javascript" src="../js/sweetalert2.js"></script>
  11. </head>
  12. <body>
  13. <center class="container">
  14. <h1> .: Personas :. </h1>
  15. <hr>
  16. <a href="../">Home</a> |
  17. <a href="crear.php">Nuevo Registro</a>
  18. <hr>
  19.  
  20. <?php
  21. $con = new mysqli('localhost', 'root', '', 'adsi120_121');
  22.  
  23. $sql = "SELECT Personas.*, ciudades.nombre as ciudad FROM Personas INNER JOIN ciudades
  24. ON Personas.id_ciudad = ciudades.id";
  25.  
  26. $resultado = $con->query($sql);
  27.  
  28. echo "<table class='table table-striped table-bordered table-hover'>
  29. <thead>
  30. <tr>
  31. <th>ID</th>
  32. <th>NOMBRE</th>
  33. <th>DIRECCION</th>
  34. <th>TELEFONO</th>
  35. <th>CIUDAD</th>
  36. <th>Editar</th>
  37. <th>Eliminar</th>
  38. </tr>
  39. </thead>
  40. <tbody>";
  41. while ( $persona = $resultado->fetch_assoc()) {
  42. echo "<tr>";
  43. echo "<td>{$persona['id']}</td>";
  44. echo "<td>{$persona['nombre']}</td>";
  45. echo "<td>{$persona['direccion']}</td>";
  46. echo "<td>{$persona['telefono']}</td>";
  47. echo "<td>{$persona['ciudad']}</td>";
  48. echo "<td> <a href='editar.php?id=$persona[id]'><img width='20' src='../imagenes/editar.png'></a> </td>";
  49. echo "<td> <a href='#' id='{$persona['id']}' onclick='confirmar(this);'><img width='20' src='../imagenes/eliminar.png'></a> </td>";
  50. echo "</tr>";
  51. }
  52. echo "</tbody></table>";
  53.  
  54.  
  55.  
  56. ?>
  57. </center>
  58. <script type="text/javascript">
  59. function confirmar(enlace){
  60. // var res = confirm('¿Desea eliminar el registro?');
  61.  
  62. // if(res){
  63. // var id = enlace.id;
  64. // window.location.href = 'eliminar.php?id='+id;
  65. // }
  66.  
  67. swal({
  68. title: '¿Desea eliminar el registro?',
  69. text: "No se puede arrepentir despues!",
  70. type: 'warning',
  71. showCancelButton: true,
  72. confirmButtonText: 'Si, eliminar!'
  73. }).then(function () {
  74. var id = enlace.id;
  75. window.location.href = 'eliminar.php?id='+id;
  76. })
  77.  
  78.  
  79. }
  80.  
  81. $('table').DataTable({
  82. "language": {
  83. "url": "../js/lang/spanish.lang"
  84. }
  85. });
  86.  
  87. </script>
  88. </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement