Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/08/2008, 07:52
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 15 años, 10 meses
Puntos: 2
Pregunta Problemas en actualizacion de catalogo

Hola compañeros, estoy hace varios dias y no logro dar con la solucion...
el tema esta en que tengo una consulta de todos los productos de mi bd (catalogoAdmin.php), mediante el cual existe dos link uno para borrar (borrarAdmin.php) y uno para actualizar productos (actualizarAdmin.php)...el problema esta en la actualizacion, no se porque no me actualizan los datos de los items que uno selecciona...
dejo los scripts para que por favor me puedan ayudar, gracias de antemano

catalogoAdmin.php
-------------------------
<?php
include('conec.php');
conectarse();
$qry=mysql_query("select id,producto,precio,descuento,(precio*descuento) montoDescuento,fecha,categoria from catalogo order by id asc");
?>
<html>
<head>
<title>Cat&aacute;logo Administrador</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="100%" align="center" cellpadding="5" cellspacing="2" border="0">
<tr valign="middle" bordercolor="#FFFFFF" bgcolor="#3399CC" class="tit">
<td align="center" width="4%"><strong>Cód.</strong></td>
<td align="center" width="45%"><strong>Nombre</strong></td>
<td align="center" width="7%"><strong>Precio<br>(S/.)</strong></td>
<td align="center" width="7%"><strong>Desc.</strong></td>
<td align="center" width="7%"><strong>Precio Final<br>(S/.)</strong></td>
<td align="center" width="10%"><strong>Fecha<br>Ingreso</strong></td>
<td align="center" width="5%"><strong>Categ.</strong></td>
<td colspan=2 align="center" width="11%"><strong>Accion</strong></td>
</tr>
<?php
while($row=mysql_fetch_assoc($qry)){
?>
<tr valign="middle" class='prod'>
<td align="center"><?php echo $row['id'] ?></td>
<td><?php echo $row['producto'] ?></td>
<td align="right"><?php echo $row['precio'] ?></td>
<td align="right"><?php echo number_format($row['montoDescuento'],2, '.', ',') ?></td>
<td align="right"><?php echo number_format(($row['precio'] - $row['montoDescuento']),2, '.', ',') ?></td>
<td align="right"><?php echo $row['fecha'] ?></td>
<td align="center"><?php echo $row['categoria'] ?></td>
<td align="center"><?php echo "<a href=\"editarAdmin.php?id=".$row['id']."\">Editar</a>" ?></td>
<td align="center"><?php echo "<a href=\"borrarAdmin.php?id=".$row['id']."\">Borrar</a>" ?></td>
</tr><?php } ?>
</table>
</body>
</html>

editarAdmin.php
---------------------
<?php
include('conec.php');
conectarse();
$registro=mysql_query("select * from catalogo where id='".$_GET['id']."'");
$row=mysql_fetch_array($registro);
?>

<html>
<head>
<title>Editando Catalogo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<form name="form2" method="post" action="actualizarAdmin.php?id=<?php echo $row["id"];?>">
<table width="70%" border="1" align="center" cellspacing="10">
<tr>
<td colspan="2" align="center">ACTUALIZACION DEL PRODUCTO</td>
</tr>
<tr>
<td>Producto</td>
<td><input name="producto" type="text" id="producto" value="<?php echo $row["producto"]?>"></td>
</tr>
<tr>
<td>Descripcion</td>
<td><input name="descripcion" type="text" id="descripcion" value="<?php echo $row["descripcion"]?>"></td>
</tr>
<tr>
<td>Precio</td>
<td><input name="precio" type="text" id="precio" value="<?php echo $row["precio"]?>"></td>
</tr>
<tr>
<td>Descuento</td>
<td><input name="descuento" type="text" id="descuento" value="<?php echo $row["descuento"]?>"></td>
</tr>
<tr>
<td>Estado</td>
<td><input name="estado" type="text" id="estado" value="<?php echo $row["estado"]?>"></td>
</tr>
<tr>
<td>Categoria</td>
<td><input name="categoria" type="text" id="categoria" value="<?php echo $row["categoria"]?>"></td>
</tr>
<tr>
<td>Stock</td>
<td><input name="stock" type="text" id="stock" value="<?php echo $row["stock"]?>"></td>
</tr>
<tr>
<td>Id Admin</td>
<td><input type="text" name="admin" id="admin" value="<?php echo $row["idAdmin"]?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="Submit" name="Submit" value="Actualizar"></td>
</tr>
</table>
</form>
</body>
</html>

actualizarAdmin.php
--------------------------
<?
include('conec.php');
conectarse();
$ids=$_GET['id'];
$producto=$_POST['producto'];
$precio=$_POST['precio'];
$descuento=$_POST['descuento'];
$estado=$_POST['estado'];
$categoria=$_POST['categoria'];
$stock=$_POST['stock'];
$admin=$_POST['admin'];
$sql="update catalogo set producto='$producto', precio='$precio', descuento='$descuento', estado='$estado', categoria='$categoria', stock='$stock', admin='$admin' where id='$ids'";
mysql_query($sql);
header("location:catalogoAdmin.php");
?>