noticias.php
Código HTML:
<body> <form action="borrar.php" method="post"> <?php include ("conexion.php"); $selec = mysql_query("SELECT * FROM noticias ORDER BY id DESC"); while ($row = mysql_fetch_array($selec)) { ?> <table width="45%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><h3><?=$row[titulo]?></h3></td> </tr> <tr> <td><h5><?=$row[nom]?></h5></td> </tr> <tr> <td><?=$row[noticia]?></td> </tr> <tr> <a href="borrar.php?id=<?=$row[id]?>">Esborrar</a> </tr> </table><br /> <? } ?> </body>
borrar.php
Código PHP:
<?
<?php
$id=$_POST[id];
include ("conexion.php");
mysql_query("DELETE FROM noticias WHERE id='$id'",$connect);
header("location: noticias.php");
?>