Ver Mensaje Individual
  #12 (permalink)  
Antiguo 04/05/2012, 14:34
echo_
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Respuesta: borrado de un registro

Gracias por su paciencia, yo lo estaba haciendo de otro modo pero no logro que me corra bien, si le doy haceptar me borra y si le doy cancelar igual tambien lo borra! este es mi codigo. saludos!

Código PHP:
[PHP]<html>
<head>


<script type="text/javascript">
function show_confirm()
{
var r=confirm("Estas seguro de borrar este registro!");
if (r==true)
  {
  <?php
   
include "config.php";

     
//
     
if (isset ($_GET['id']) || !empty ($_GET['id'])){
     
$result=mysql_query("delete from usuarios WHERE id = '$id' ",$conexion);
 
     }
    
?>
  
  alert("Ha borrado el Registro");
  }
else
  {
  alert("Ha cancelado!");
  }
}
</script>








<title>registros</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="contenido">
  <div id="cabecera"></div>
  <div id="separacion"></div>
  
  
  
  <?php
 
  
//Funcion para el cebreado cada 1   registro.
   
function alt ($cebra) {
   if (
$cebra/==               floor($cebra/2)) {
    return 
' class="a"';
    } else {
        return 
' class="b"';
    }
}
$cebra=1;



     
    


     
$result=mysql_query("SELECT * FROM usuarios ORDER BY id",  $conexion);
    
     
$num_results mysql_num_rows ($result);

     for( 
$i=1$i<=$num_results$i++ ) {  
     
      
$row mysql_fetch_array ($result);  
     
?>

  

  
  <div <?php echo alt($zebra); $zebra++;?>>
  <?php echo'<table width="596" border="0">
      <tr>
        <td width="58">'
.$row[0].'</td>
        <td width="142">'
.$row[1].'</td>
        <td width="125">'
.$row[1].'</td>
        <td width="117">'
.$row[3].'</td>
        <td width="120"><a href="index.php?id='
.$row[0].'"><img onclick="show_confirm()" value="Show a confirm box"  src="delete-32.png" width="16" height="16"></a><td width="160">  </td>
      </tr>
    </table>
  </div>'
;
  
  } 
  
  
//<a href="index.php?id='.$row[0].'">Mi enlace</a></td>
  
?>
<p>&nbsp;</p>
</div>
</body>
</html>
[/PHP]