Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/08/2005, 11:20
Avatar de The_omars
The_omars
 
Fecha de Ingreso: marzo-2004
Mensajes: 271
Antigüedad: 20 años, 1 mes
Puntos: 0
agregar filas con sesiones?

hola compañeros.

solo para preguntar:

he intentado hacer que un usuario agrege y quite filas de una tabla n veces
lo estoy haciendo con sesiones pero realmente no me sale he tomado como ejemplo este codigo:

Código PHP:
session_start(); 
session_register('itemsEnCesta'); 
$item=$_POST['item']; 
$cantidad=$_POST['cantidad']; 
echo $itemsEnCesta=$_SESSION['itemsEnCesta']; 

if ($item){ 
   if (!isset($itemsEnCesta)){ 
      $itemsEnCesta[$item]=$cantidad; 
   }else{ 
      foreach($itemsEnCesta as $k => $v){ 
         if ($item==$k){ 
         $itemsEnCesta[$k]+=$cantidad; 
         $encontrado=1; 
         } 
      } 
      if (!$encontrado) $itemsEnCesta[$item]=$cantidad; 
   } 

$_SESSION['itemsEnCesta']=$itemsEnCesta; 
?> 
<html> 
<body> 
<tt> 
<form action="consulta2.php" method="post"> 
Dime el producto <input type="text" name="item" size="20"><br> 
Cuantas unidades <input type="text" name="cantidad" size="20"><br> 
<input type="submit" value="Anadir a la cesta"><br> 
</form> 
<? 
if (isset($itemsEnCesta)){ 
   echo
'El contenido de la cesta de la compra es:<br>'
   foreach(
$itemsEnCesta as $k => $v){ 
      echo 
'Articulo: '.$k.' ud: '.$v.'<br>'
   } 
}
lo he estado probando pero no llego a mi objetivo.

lo unico que quiero hacer es que de una tabla, el usuario agrege una fila
con sessiones.



ejemplo:

------------------------
tabla
------------------------
Columna por defoul
------------------------

__________________
agregar fila a la tabla| /// Boton
__________________|


no se si tengan algun ejemplo

por su ayuda gracias