Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2007, 12:11
yairo_gioel
 
Fecha de Ingreso: abril-2007
Mensajes: 20
Antigüedad: 17 años
Puntos: 0
Error al actualizar...!!!

Hola. En una pagina datos_bebidas.php muestro una tabla con todos los codigos y bebidas que existen en mi base de datos... y cada fila tiene un boton ACTUALIZAR y un enlace (href) ELIMINAR... el enlace eliminar funciona perfecto, pero cuando presiono el boton ACTUALIZAR, solo actualiza el ultimo registro... y tengo los datos ordenados por codigo de la bebida, es decir que solo me permite actualizar la ultima bebida ingresada, pero yo quiero que si presiono en el boton ACTUALIZAR de la segunda fila actualice el nombre de la segunda fila, me explico? aca estan las paginas.


DATOS_BEBIDAS.PHP

<?php
session_start();
if($_SESSION['nivel']==1){
}else{
//header("Location: bebidas.php?error=No tiene acceso al club de socios");
}
?>
<? include("../conexion.php");?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
a:link {
color: #CC0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #CC0000;
}
a:hover {
text-decoration: underline;
color: #CC0000;
}
a:active {
text-decoration: none;
color: #CC0000;
}
.Estilo1 { font-weight: bold;
color: #FFFFFF;
font-style: italic;
}
-->
</style></head>

<body>
<table width="69%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td><div align="center"><a href="file:///C|/webs/home/hidesa/agregar_usuario.php">Agregar bebida </a> | <a href="file:///C|/webs/home/socios/.php">Modificar datos </a></div></td>
</tr>
</table>
<hr>
<h1 align="center"><u>Listado</u></h1>
<form name="form1" method="get" action="actualizar_bebida.php">
<table width="72%" border="1" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="29%"><div align="center" class="Estilo1 ">
<h3><u>CODIGO</u></h3>
</div></td>
<td width="29%"><div align="center" class="Estilo1">
<h3><u>BEBIDA</u></h3>
</div></td>
<td colspan="2"><div align="center" class="Estilo1">
<h3><u>MODIFICAR DATOS </u></h3>
</div></td>
</tr>
<?php
$link=Conectarse();
$datos_bebida=mysql_query("select textbebida,codbebida,nombebida from bebidas order by codbebida",$link); ?>

<?php while($row=mysql_fetch_array($datos_bebida)){ ?>
<tr>
<td height="48"><div align="center">
<label>
<input name="codigo" type="text" disabled="disabled" id="codbebida2" value="<?php echo $row[0] ?><?php echo $row[1] ?>">
</label>
</div></td>
<td><div align="center">
<label>
<input name="nombebida" type="text" id="nombebida" value="<?php echo $row[2] ?>">
</label>
</div></td>
<td width="21%"><div align="center">
<label>
<input name="codbebida" type="text" id="codbebida3" value="<?php echo $row[1] ?>"><input type="submit" name="Submit2" value="Actualizar">
</label>
</div></td>
<td width="21%"><div align="center"><a href="eliminar_bebida.php?codbebida=<?php echo $row[1] ?>">Eliminar</a></div></td>
</tr>
<? } mysql_close($link)?>
</table>
</form>
<hr>
</body>
</html>


ACTUALIZAR_BEBIDA.PHP

<?php
session_start();
if($_SESSION['nivel']==1){
}else{
//header("Location: datos_bebidas.php?error=No tiene acceso al club de socios");
}
?>
<? include("../conexion.php");?>
<?php
$codbebida=$_GET['codbebida'];
$nombebida=$_GET['nombebida'];
$link=Conectarse();

$sql_1 = "UPDATE bebidas SET nombebida='$nombebida' WHERE codbebida='$codbebida'";
mysql_query($sql_1);


header("Location: datos_bebidas.php");
echo "¡BEBIDA MODIFICADA CON EXITO!";
?>