Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
- <link rel="stylesheet" type="text/css" href="../css/datatables.css">
- <link rel="stylesheet" type="text/css" href="../css/sweetalert2.css">
- <script type="text/javascript" src="../js/jquery.js"></script>
- <script type="text/javascript" src="../js/datatables.js"></script>
- <script type="text/javascript" src="../js/sweetalert2.js"></script>
- </head>
- <body>
- <center class="container">
- <h1> .: Personas :. </h1>
- <hr>
- <a href="../">Home</a> |
- <a href="crear.php">Nuevo Registro</a>
- <hr>
- <?php
- $con = new mysqli('localhost', 'root', '', 'adsi120_121');
- $sql = "SELECT Personas.*, ciudades.nombre as ciudad FROM Personas INNER JOIN ciudades
- ON Personas.id_ciudad = ciudades.id";
- $resultado = $con->query($sql);
- echo "<table class='table table-striped table-bordered table-hover'>
- <thead>
- <tr>
- <th>ID</th>
- <th>NOMBRE</th>
- <th>DIRECCION</th>
- <th>TELEFONO</th>
- <th>CIUDAD</th>
- <th>Editar</th>
- <th>Eliminar</th>
- </tr>
- </thead>
- <tbody>";
- while ( $persona = $resultado->fetch_assoc()) {
- echo "<tr>";
- echo "<td>{$persona['id']}</td>";
- echo "<td>{$persona['nombre']}</td>";
- echo "<td>{$persona['direccion']}</td>";
- echo "<td>{$persona['telefono']}</td>";
- echo "<td>{$persona['ciudad']}</td>";
- echo "<td> <a href='editar.php?id=$persona[id]'><img width='20' src='../imagenes/editar.png'></a> </td>";
- echo "<td> <a href='#' id='{$persona['id']}' onclick='confirmar(this);'><img width='20' src='../imagenes/eliminar.png'></a> </td>";
- echo "</tr>";
- }
- echo "</tbody></table>";
- ?>
- </center>
- <script type="text/javascript">
- function confirmar(enlace){
- // var res = confirm('¿Desea eliminar el registro?');
- // if(res){
- // var id = enlace.id;
- // window.location.href = 'eliminar.php?id='+id;
- // }
- swal({
- title: '¿Desea eliminar el registro?',
- text: "No se puede arrepentir despues!",
- type: 'warning',
- showCancelButton: true,
- confirmButtonText: 'Si, eliminar!'
- }).then(function () {
- var id = enlace.id;
- window.location.href = 'eliminar.php?id='+id;
- })
- }
- $('table').DataTable({
- "language": {
- "url": "../js/lang/spanish.lang"
- }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement