Foros del Web » Programando para Internet » PHP »

eliminacion con php

Estas en el tema de eliminacion con php en el foro de PHP en Foros del Web. hola tengo un problema quiero eliminar registros de una base de datos.... hice el formulario, y me muestra los registros pero al darle click a ...
  #1 (permalink)  
Antiguo 10/09/2008, 14:35
 
Fecha de Ingreso: agosto-2008
Mensajes: 94
Antigüedad: 15 años, 8 meses
Puntos: 0
eliminacion con php

hola tengo un problema quiero eliminar registros de una base de datos.... hice el formulario, y me muestra los registros pero al darle click a borrar no pasa nada... aqui coloco los dos archivos...porfa cualquiera que me puediera ayudar se lo agradeceria...

----------------------------------------
ejemplo_de_borrar.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Georgia;
font-size: large;
font-style: italic;
font-weight: bold;
color: #000066;
}
.style2 {
font-family: Georgia;
font-size: medium;
color: #000066;
font-style: italic;
font-weight: bold;
}
-->
</style>
</head>

<body>
<H1 align="left" class="style1">
<label>
<input type="image" name="imageField" id="imageField" src="logocantv.jpg" />
</label>
</H1>
<H1 align="left" class="style1">
<label>
<input type="image" name="imageField2" id="imageField2" src="cabecera_gobenlinea.gif" />
</label>
</H1>
<H1 align="center" class="style1">&nbsp;</H1>
<marquee bgcolor="#FFFFFF" width="100%" scrolldelay="100" scrollamount="4" loop="infinite">
<div align="center" class="style4 style5"><h2 align="left" class="style12">
<h2 align="center" class="style9 style1">BIENVENIDO AL SISTEMA DE GESTION DE SERVICIOS OCASIONALES (GESEO)</h2>
<p align="center" class="style9">&nbsp;</p>
</div>
</marquee>
<H1 align="center" class="style1">&nbsp;</H1>
<H1 align="center" class="style1">ELIMINACION DE SERVICIOS</H1>
<H1 align="center" class="style1">&nbsp;</H1>
<form name="orden" method="get" action="borrar.php" onSubmit="return check_campos(this)">

<?php
include("funciones.php");
$link=con_db();
$result=mysql_query("select * from servicio_voz");

?>

<TABLE width="820" height="21" BORDER=1 CELLPADDING=0 CELLSPACING=0 bordercolor="#000066">
<TD width="159"> <div align="center"><B>N° DE SOLICITUD</B> </div></TD>
<TD width="159"> <div align="center"><B>RIF CLIENTE</B> </div></TD>
<TD width="231"> <div align="center"><B>NOMBRE DEL EVENTO</B> </div></TD>
<TD width="197"> <div align="center"><B>FECHA DE CREACION</B> </div></TD>
<TD width="58"> <div align="center"><B>BORRAR</B> </div></TD>
</TR>
<?php

while($row = mysql_fetch_array($result)) {
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href=\"borra.php?cod_servi=%d\">Borra</a></td></tr>", $row["cod_ser"],$row["cod_cli"],$row["nom_eve"],$row["fec_crea"], $row["cod_ser"]);
}
mysql_free_result($result);
descon_db();
?>


<?php

$result=mysql_query("select * from servicio_datos");

?>
<?php

while($row = mysql_fetch_array($result)) {
printf("<tr><td> %s</td><td>%s</td><td>%s</td><td>%s</td><td><a href=\"borra.php?cod_servi=%d\">Borra</a></td></tr>", $row["cod_ser"],$row["cod_cli"],$row["nom_eve"],$row["fec_crea"], $row["cod_ser"]);
}
mysql_free_result($result);
descon_db();
?>



<?php

$result=mysql_query("select * from servicio_video");

?>
<?php

while($row = mysql_fetch_array($result)) {
printf("<tr><td> %s</td><td>%s</td><td>%s</td><td>%s</td><td><a href=\"borra.php?cod_servi=%d\">Borra</a></td></tr>", $row["cod_ser"],$row["cod_cli"],$row["nom_eve"],$row["fec_crea"], $row["cod_ser"]);
}
mysql_free_result($result);
descon_db();
?>
</table>
<p>&nbsp;</p>
<table align="center">
<td colspan="6"><div align="center" class="style21">
<h5>
<label></label>
</h5>
<p><span class="style22 style2"><a href="ingresacon.php" target="_parent" class="style22">Regresar al Menu Principal </a></span></p>
</div></td>
</tr>
</table>
</body>
</html>



------------------------------------------
borra.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
include("funciones.php");
$link=con_db();
$cod_servi=$_GET['cod_servi'];
mysql_query("delete from servicio_voz where cod_ser=$cod_servi",$link);

header("Location: ejemplo_de_borrar.php");
?>

<?php

$cod_servi=$_POST['cod_servi'];
mysql_query("delete from servicio_video where cod_ser=$cod_servi",$link);

header("Location: ejemplo_de_borrar.php");
?>

<?php

$cod_servi=$_POST['cod_servi'];
mysql_query("delete from servicio_datos where cod_ser=$cod_servi",$link);

header("Location: ejemplo_de_borrar.php");
?>


</body>
</html>
  #2 (permalink)  
Antiguo 10/09/2008, 14:52
Avatar de the_web_saint  
Fecha de Ingreso: mayo-2008
Ubicación: localhost/tierra/america/panama
Mensajes: 1.229
Antigüedad: 15 años, 11 meses
Puntos: 43
Respuesta: eliminacion con php

Prueba de esta manera.
Cita:
mysql_query("delete from servicio_voz where cod_ser=".$cod_servi ,$link);
De todas formas fijate si al colocar el mouse sobre el link, la url en la barra de estado es correcta, osea, si envia el id correctamente.

Si envias los datos a travez de url, se retoman con GET
__________________
..::The Saint::..
El pesimista se queja del viento; el optimista espera que cambie; el realista ajusta las velas.
  #3 (permalink)  
Antiguo 10/09/2008, 16:49
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Respuesta: eliminacion con php

yo te recomiendo poner

Código PHP:
mysql_query("DELETE FROM servicio_voz WHERE cod_ser = '$cod_servi' " ,$link); 
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #4 (permalink)  
Antiguo 11/09/2008, 10:18
 
Fecha de Ingreso: agosto-2008
Mensajes: 94
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: eliminacion con php

hola gracias por su ayuda... ya me elimina; pero al darl click a un registro me elimina todos los registros, y nada mas quiero que se le elimine al que le de click que condicion debo colocar para que lo hag.....
  #5 (permalink)  
Antiguo 11/09/2008, 10:19
 
Fecha de Ingreso: agosto-2008
Mensajes: 94
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: eliminacion con php

el borra.php lo deje de esta manera....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
include("funciones.php");
con_db();
$cod_servi=$_GET['cod_servi'];
mysql_query("delete from servicio_video where cod_ser=$cod_servi");

header("Location: ejemplo_de_borrar.php");
?>

<?php

$cod_servi=$_GET['cod_servi'];

mysql_query("DELETE FROM servicio_voz WHERE cod_ser =$cod_servi");

header("Location: ejemplo_de_borrar.php");

?>

<?php

$cod_servi=$_GET['cod_servi'];
mysql_query("delete from servicio_datos where cod_ser=$cod_servi");

header("Location: ejemplo_de_borrar.php");
?>
</body>
</html>
  #6 (permalink)  
Antiguo 16/09/2008, 23:39
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Respuesta: eliminacion con php

no entiendo, tu problema se supone que con el WHERE y AND'S sle dices a tu consulta que deceas eliminar actualizar etc... en especifico, entonces creo que lo tuyo es solo problema de asignacion de nombres de variables ademas has impreso que valores toma lo que traes por GET????

saludos
__________________
Gokuh Salvo al mundo. PUNTO!!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:00.