Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/02/2004, 14:46
Tenken
 
Fecha de Ingreso: febrero-2004
Mensajes: 1
Antigüedad: 20 años, 2 meses
Puntos: 0
update en SQL

Ayudenme por favor!!!!.
Tengo una base de datos de una muebleria, la cual tiene una tabla llamada inventario, dentro de esta el campo existencias, este campo deberia de incrementarse segun la cantidad que se ingresa desde un formulario que este en html, el formulario pide datos sobre los muebles y la cantidad de muebles a ingresar, los datos se mandan a otra tabla, lo cual si lo hace, el problema es que las existencias en la tabla inventario no se incrementan.
El codigo que tenemos para tratar de realizar esto es:

libreria se nanda a llamar para conectarse.

<html>

<head>
<title>ALTAS DE ACCESORIOS</title>
<link href="estilo.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="25" link="#002266" vlink="#002266" alink="#002269" text="#FFFFFF" bgcolor="#000066">

<form action="aaccesorios.php" method=post>

<CENTER>
<BR>
<FONT SIZE=5>DAR DE ALTA ACCESORIOS</FONT><BR><BR>
<CENTER>

<table border="1" cellpadding="3" cellspacing="3" align=center>
<tr>
<th>ID:</th> <td><input type=text name="id"></td>
</tr>

<tr>
<th>CLAVE_PRODUCTO</th><td><input type=text name="cp"></td>
</tr>

<tr>
<th>CANTIDAD</th><td><input type=text name="cant"></td>
</tr>

<tr>
<th>MATERIAL</th><td><input type=text name="mat"></td>
</tr>

<tr>
<th>TIPO</th><td><input type=text name="tip"></td>
</tr>

<tr>
<th>ESTILO</th><td><input type=text name="est"></td>
</tr>

<tr>
<th>MODELO</th><td><input type=text name="mod"></td>
</tr>

<tr>
<th>DESCRIPCIÓN</th><td><input type=text name="des"></td>
</tr>

<tr>
<th>PRECIO</th><td><input type=text name="pre"></td>
</tr>

<tr>
<th>ID_PROVEEDOR</th><td><input type=text name="idp"></td>
</tr>

</table>

<BR>
<center>
<input type=submit value="Insertar registro >>">
</center>
</form>

<BR><BR><TABLE>

<?php

include("libreria.php");

$link=conectarse();

if(!empty($id))
{
// values ('$id','$cp', '$mat', '$tip','$est','$mod','$des','$pre')";from accesorios

$consulta = " select ID,CLAVE_PRODUCTO, MATERIAL, TIPO, ESTILO, MODELO, DESCRIPCIÓN, PRECIO from accesorios where id='$id'";

$result=mysql_query($consulta,$link);

while($row = mysql_fetch_array($result))
{ echo "\n <tr>";
echo "\n <td>".$row['ID']."</font ></td>";
echo "\n <td>".$row['CLAVE_PRODUCTO']."</font ></td>";
echo "\n <td>".$row['MATERIAL']."</font ></td>";
echo "\n <td>".$row['TIPO']."</font></td>";
echo "\n <td>".$row['ESTILO']."</font></td>";
echo "\n <td>".$row['MODELO']."</font></td>";
echo "\n <td>".$row['DESCRIPCIÓN']."</font></td>";
echo "\n <td>".$row['PRECIO']."</font></td>";
echo "\n </tr>";
//$i++;
}

$mera = "select EXISTENCIAS from inventario where id='$id'";
echo $mera;
$soma = mysql_query($mera,$link);
// while($row2 = mysql_fetch_array($soma))
{
echo "<tr> <td>".$row2['EXISTENCIAS']."</font ></td></tr>"; //son mayusculas
// $pi=$row2['EXISTENCIAS'];
$aux=$cant+$row2;
echo "<tr><td>HOLA1:".$aux."</td></tr>";
}
}

echo $row2;
echo "<tr><td>HOLA:".$pi."</td></tr>";

$consulta2 = " insert into inventario (ID,ID_PROVEEDOR, PRECIO) values ('$id','$idp', '$pre') ";

$cantidad3 = " insert into altas (ID, CLAVE_PRODUCTO, ID_PROVEEDOR, CANTIDAD) values ('$id', '$cp', '$idp','$cant') ";

//$consulta3="insert into accesorios (CANTIDAD) values ('$cant'+ CANTIDAD) where ID='$id'";

if( mysql_query($consulta,$link))
echo " Insercion exitosa<br>";
else
echo " Insercion NO exitosa<br>";

if( mysql_query($consulta2,$link))
echo " Insercion exitosa a inventario";
else
echo " Insercion NO exitosa a inventario";
if( mysql_query($cantidad3,$link))
echo " Insercion exitosa a ALTAS";
else
echo " Insercion NO exitosa a ALTAS";


mysql_close($link); //cierra la conexion





echo "<tr><td>".$aux."</td></tr>";

include("libreria.php");

$link=conectarse();

$nuevaexist = "update inventario set EXISTENCIAS=$aux where ID=$id";
{
//where ID=$id (EXISTENCIAS=$aux);
//$consulta2="insert into inventario (EXISTENCIAS) values ('$id','$idp', '$pre')";
}

mysql_close($link); //cierra la conexion

?>

</body>

</html>




Por favor respondan a la brevedad posible.