Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/11/2008, 14:27
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 15 años, 10 meses
Puntos: 2
Respuesta: Se puede añadir una columna a una sesion

Agradesco tu respuesta foreverOdd,
el listado de la sesion $_SESSION['carro'] la obtengo asi:

foreach($carro as $k => $v){
$subto=$v['cantidad']*$v['precio'];
$suma=$suma+$subto;
$contador++;
?>
<form name="a<?php echo $v['identificador'] ?>" method="post" action="agregacar.php?<?php echo SID ?>" id="a<?php echo $v['identificador'] ?>">
<tr bgcolor="<?php echo $color[$contador%2]; ?>" class='prod'>
<td><?php echo $v['producto'] ?></td>
<td><?php echo $v['precio'] ?></td>
<td width="43" align="center"><?php echo $v['cantidad'] ?></td>
<td width="136" align="center">
<input name="cantidad" type="text" id="cantidad" value="<?php echo $v['cantidad'] ?>" size="8">
<input name="id" type="hidden" id="id" value="<?php echo $v['id'] ?>"></td>
<td align="center">
<input name="imageField" type="image" src="actualizar.gif" width="20" height="20" border="0"></td>
</tr></form>
<?php }?>

agregacarrito.php //este php agrega una cantidad por c/item
<?php
session_start();
extract($_REQUEST);
include('conec.php');
conectarse();
if(!isset($cantidad)){$cantidad=1;}
$qry=mysql_query("select * from catalogo where id='".$id."'");
$row=mysql_fetch_array($qry);
if(isset($_SESSION['carro']))
$carro=$_SESSION['carro'];
$carro[md5($id)]=array('identificador'=>md5($id),'cantidad'=>$cant idad,'producto'=>$row['producto'],'precio'=>$row['precio'],'id'=>$id);
$_SESSION['carro']=$carro;
header("Location:vercarrito.php?".SID);
?>

visualizandolo de esta manera este codigo añade la cantidad solicitada por cada item,
pero se puede agregar con un solo type=image
<input name="imageField" type="image" src="actualizar.gif" width="20" height="20" border="0"> y actualizar los datos de la sesion (incluyendo para c/item su cantidad solicitada)

gracias de antemano