Ver Mensaje Individual
  #17 (permalink)  
Antiguo 04/05/2012, 15:55
Avatar de BLAH !!
BLAH !!
 
Fecha de Ingreso: septiembre-2003
Ubicación: Región Metropolitana, Santiago, Chile
Mensajes: 706
Antigüedad: 20 años, 7 meses
Puntos: 16
Respuesta: borrado de un registro

OK, ya que no interpretas bien el codigo que te mando, lo voy a hacer para ti ... este es todo tu INDEX.PHP

Código PHP:
<?php
   
include ("config.php");
if(
$_GET['action']=="delete"){
$id$_GET['id'];
 
$delete "DELETE FROM usuarios WHERE id='$id'";
 
$del mysql_query($delete) or die (mysql_error());
 
$opt "OPTIMIZE TABLE usuarios";
 
$rop mysql_query($opt);
};
?> 

<html>
<head>

<SCRIPT>
function show_confirm(id){
 var r=window.confirm("Estas seguro de borrar este registro?");
 if (r==true){
  window.location="archivo.php?action=delete&id="+id;
 }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);
     
$row mysql_fetch_array ($result);  
     for( 
$i=1$i<=$num_results$i++ ) {  

?>


  <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 style="cursor:pointer; cursor: hand;" onClick="show_confirm(\'".$row[id]."\')"><img alt="Show a confirm box"  src="delete-32.png" width="16" height="16"></a></td>
        <td width="160">  </td>
      </tr>
    </table>
  </div>'
;
  
  } 
 
?>
<p>&nbsp;</p>
</div>
</body>
</html>
__________________
Adios ...!!!!