Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/12/2008, 23:32
Ozkar_86
 
Fecha de Ingreso: febrero-2008
Mensajes: 38
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Eliminar registro

Código PHP:
<?php
$conexion 
mysql_connect('localhost''pablo''pablo');
mysql_select_db('auto concept club');

//siempre el codigo de las operaciones ponlo al principio para tener un orden
if($_GET['id_del']) // le pongo id_del por identificador de delete (borrado)
{
$sSQL="Delete From noticias Where idnoticias='".$_GET['id_del']."'";
mysql_query($sSQL);

// ojo estoy poniendo idnoticias como primary_key de tu tabla
}

?>
Código HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: Aprendiendo PHP =P</title>
</head>

<body>
<?php
$queEmp = "SELECT * FROM noticias ORDER BY fecha DESC";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);


while ($registro = mysql_fetch_array($resEmp)) 
{

<div id="tabla">
  <table width="410" border="0" cellpadding="1" cellspacing="4" bordercolor="#000000">
    <tr>
      <td width="35%" class="Estilo4"><?php echo $registro['fecha']; ?></td>
      <td width="26%">&nbsp;</td>
      <td width="20%">&nbsp;</td>
      <td width="19%">&nbsp;</td>
    </tr>
    <tr>
      <td class="Estilo1"><?php echo $registro['titulo']; ?></td>
      <td class="Estilo4"><?php echo $registro['zona']; ?></td>
      <td class="Estilo7"><div align="center">Modificar</div></td>
      <td class="Estilo7"><a ref=tabla_noticias.php?id_del=<?php echo $idnoticias?>>Eliminar</a></td>
    </tr>
    <tr>
      <td colspan="4" class="Estilo2"><?php echo $registro['noticia_completa']; ?></td>
    </tr>
<?php
}
mysql_free_result($resEmp);
mysql_close($conexion);
?>
</table>
</div>
</body>
</html> 

Como sugerencia puedes ponerle a tu boton

Código HTML:
<a onclick="willSubmit=confirm('&iquest;Esta seguro de eliminar este registro?'); return willSubmit;" ref="tabla_noticias.php?id_del=<?php echo $idnoticias?>" title="Eliminar">Eliminar</a>
           
Errores cometidos

if (eliminar==1) // eliminar no es variable php, tuviste q haber puesto $eliminar ademas como es variable recibida tuvo que haber sido $_GET['eliminar'] ademas esta consulta se hace afuera espero funcione lo revise a la volada me avisas como te fue
$sSQL = "Delete From noticias Where idnoticias = '$ID'";