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

archivo .php
Código PHP:
<?php
...
require(
"conectar-bd.php");
...
if(
$_GET['action']=="delete"){
$erase $_GET['erase'];
 
$delete "DELETE FROM table WHERE id='$erase'";
 
$del mysql_query($delete) or die (mysql_error());
 
$opt "OPTIMIZE TABLE table";
 
$rop mysql_query($opt);
};
?>
...
 <SCRIPT src="archivo.js" language="Javascript" type="text/javascript"></SCRIPT> 
...
<a style="cursor:pointer; cursor: hand;" onClick="eliminar('$id');">ELIMINAR</a>

archivo.js
Código PHP:
function eliminar(id) {
 var 
consulta window.confirm("Desea eliminar archivo id : '"+id+"' ?");
  if (
consulta == true){
      
window.location="archivo.php?action=delete&erase="+id;
  }else{
      
alert("Ha cancelado");
  }

El OPTIMIZE es para purgar la tabla
Cita:
OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns).
__________________
Adios ...!!!!