Advertisement
Guest User

php funciones eliminar

a guest
May 10th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. function  listar_noticias($conexion){
  2.     ?>
  3.  <table class="table">
  4.     <thead>
  5.      <tr>
  6.         <th>ID</th>
  7.         <th>Autor</th>
  8.         <th>Titulo</th>
  9.         <th>Categoria</th>
  10.         <th>Update</th>
  11.         <th >Editar</th>
  12.         <th>Eliminar</th>
  13.       </tr>
  14.     </thead>
  15.     <?php
  16. $sql = "SELECT * FROM noticias ORDER BY id ASC ";
  17.         $resultado = $conexion->query($sql);
  18.         while($row = mysqli_fetch_array($resultado))
  19.         {
  20.         ?>
  21.         <tbody>
  22.         <tr>
  23.           <td><?php echo $row['id']; ?></td>
  24.           <td><?php echo $row['autor']; ?></td>
  25.           <td><?php echo $row['titulo']; ?></td>
  26.           <td><?php echo $row['categoria']; ?></td>
  27.           <td><?php echo $row['update']; ?></td>
  28.           <td><a href="#">Editar</a></td>
  29.           <td><a href="./elim.php?id=<?php echo $row ['id']; ?>">Eliminar</a></td>
  30.         </tr>
  31.      </tbody>
  32.     <?php
  33.         }
  34.         ?>
  35. </table>
  36. <?php
  37.  
  38. }
  39.  
  40. function eliminar_noticia($conexion){
  41.         $id = $_GET['id'];
  42.  
  43.         $sql = "DELETE FROM noticias WHERE id = '$id'";
  44.         $resultado = $conexion->query($sql);
  45.  
  46.         if ($resultado) {
  47.  
  48.          echo "El registro fue eliminado correctamente";
  49.  
  50.         } else {
  51.  
  52.          echo  "Error al eliminar el registro selecionado";
  53.  
  54.     }
  55.     return $id;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement