Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/09/2006, 13:38
Anthonn
 
Fecha de Ingreso: septiembre-2006
Mensajes: 7
Antigüedad: 17 años, 7 meses
Puntos: 0
Gracias

Hola FNX_NET, mira este es el codigo de mi carrito, el cual no me muestra ningun valor...aunque tampoco me marca ningun error.. ya se me esta quemando el cerebro..ojala puedas ayudarme..gracias

<?session_start();?>
<html>
<head>
<title>Carrito de compras</title>
</head>
<body>
<?
$conexion=mysql_connect("localhost","antonio","123 45");
mysql_select_db("dblaselva",$conexion);
//Obtenemos los detalles del articulo a agregar
$query="select * from articulo where codigo='$_POST[clave]'";
$result=mysql_query($query,$conexion);
$row=mysql_fetch_array($result);
$nombre=$row['nombre'];
$precio=$row['precio'];
$cantidad=1;
$importe=$precio*$cantidad;
echo $importe;
//Insertamos el articulo al carrito
$query="insert into carrito values ($clave,$nombre,$precio,$cantidad,$importe)";
$result=mysql_query($query,$conexion);
//Verificamos que el articulo aun no este en el carrito
$query="select * from carrito";
$result=mysql_query($query,$conexion);
if ($row=mysql_fetch_array($result)){
//el articulo ya esta en el carrito
$cantidad=$row['cantidad']+1;
$importe=$cantidad*$row['precio'];
$query="update carrito set cantidad='$_POST[cantidad]', importe='$_POST[importe] where codigo='$_POST[clave]'";
$result=mysql_query($query,$conexion);
}
else
{
//Desplegamos el contenido del carrito
$query="select * from carrito";
$result=mysql_query($query,$conexion);
echo "<table border=1>";
echo "<tr><td>Clave</td><td>Nombre</td><td>Precio</td><td>Cantidad</td><td>Importe</td></tr>";
$subtotal=0;}
while ($row=mysql_fetch_array($result))
{
echo "<tr><td>",$row['clave'];
echo "</td><td>",$row['nombre'];
echo "</td><td>",$row['precio'];
echo "</td><td>",$row['cantidad'];
echo "</td><td> <input type=text size=5 value=1",$row['cantidad'],">";
echo "</td><td>",$row['importe'],"</td></tr>";
$subtotal=$subtotal+$row['importe'];
}
echo "</table border='1'><br><br>";
echo "<td>subtotal:</td> ",$subtotal;
echo "<br><td> Iva: </td> ",$subtotal*0.15;
echo "<br> Total: ",$subtotal*1.15;
echo "</table>";
echo "<br>";
echo "<a href='catalogo.php'>Seguir comprando</a>";

?>
</body>
</html>