Ver Mensaje Individual
  #11 (permalink)  
Antiguo 24/07/2007, 03:55
miketrix_esp
 
Fecha de Ingreso: enero-2005
Ubicación: Barcelona
Mensajes: 384
Antigüedad: 19 años, 3 meses
Puntos: 0
Re: Mi carrito de la compra es muy raro...

Cita:
Iniciado por albalate Ver Mensaje
Código PHP:
<?
session_start
();
if (!isset(
$_SESSION["itemsencesta"]))
{
    
session_register("itemsencesta");
    
$_SESSION["itemsencesta"];
    
$itemsencesta=array();
    
$itemsencesta=$_SESSION["itemsencesta"];
}
$item=$_POST['item'];
$talla=$_POST['talla'];
$color=$_POST['color'];
if (isset(
$item))
    {
            
$itemsencesta = array(
            
referencia=>$item,
            
color=>$color,
            
talla=>$talla,
            
cantidad=>1
            
);
            
$_SESSION["itemsencesta"][]=$itemsencesta;
            
array_push($_SESSION["itemsencesta"],$itemsencesta);
    }
    else
    {

    }


?>
<html>
<body>
<tt>
<form action="<?=$PHP_SELF."?".$SID?>" method="post">
Referencia: <input type="text" name="item" size="20"><br>
Talla: <input type="text" name="talla" size="20"><br>
Color: <input type="text" name="color" size="20"><br>
<input type="submit" value="Añadir al Carrito"><br>
</form>
<?
    
echo'El contenido del carrito es:<br>';
    foreach(
$itemsencesta as $ku=>$v)
    {
        echo 
"Producto[" $ku "] = " $v "";
        echo 
"<pre>";
        foreach( 
$v as $key => $value )
        {
            echo 
"Key[" $key "] = " $value "<br>";
        }
        echo 
"</pre>";
    }
?>
</tt>
</body>
</html>
Quita el
Código PHP:
$_SESSION["itemsencesta"][]=$itemsencesta
que es lo que esta machacando las cosas que guardas. Y arriba declara la $_SESSION["itemsencesta"] como array
Código PHP:
$_SESSION["itemsencesta"] = array(); 
__________________
m!ketrix
CINE25 - Red Social de Cine
byinspiroh