Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/09/2011, 16:14
Avatar de hasdpk
hasdpk
 
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 8 meses
Puntos: 297
Respuesta: Problema con borrar registros

Prueba con este código a ver si te funciona:

Código PHP:
Ver original
  1. <?php
  2.  
  3.     conectar_mysql();
  4.  
  5.     if($_POST["borrar"]) {
  6.  
  7.         mysql_query("DELETE * FROM noticias WHERE id_noticia='{$_POST['id']}'");
  8.     }
  9.  
  10.     $consulta = mysql_query("SELECT * FROM noticias order by id_noticia desc");
  11.  
  12.     while ($reg = mysql_fetch_array($consulta)){ ?>
  13.  
  14.         <div>
  15.        
  16.             <p>
  17.            
  18.                 <strong><?php echo $reg['titulo_noticia']; ?></strong><br />
  19.                 <span>Publicado el <?php echo $reg['fecha']; ?></span>
  20.                
  21.             </p>
  22.            
  23.             <p>
  24.            
  25.                 <?php echo $reg['noticia']; ?>
  26.  
  27.             </p>
  28.            
  29.             <form method="post">
  30.            
  31.                 <input type="hidden" name="id" value="<?php echo $reg['id_noticia']; ?>">
  32.                 <input type="submit" name="borrar" value="Borrar" />
  33.            
  34.             </form>
  35.        
  36.         </div>
  37.        
  38.     <?php }
  39.        
  40.     mysql_close();
  41.  
  42. ?>

Última edición por hasdpk; 16/09/2011 a las 16:28