Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/01/2004, 06:25
alexei
 
Fecha de Ingreso: marzo-2003
Mensajes: 34
Antigüedad: 21 años, 1 mes
Puntos: 0
Pregunta borrar variables sesion

hola quetal:

estoy usando el carito de webestilo, y me funciona perfecto, pero le falta una cosa que necesito, y no tengo ni idea de hacerla, borrar variable que ya he añadido.



he aqui el script de webestilo:

<?php // Manual de PHP de WebEstilo.com
session_start();
session_register('itemsEnCesta');
$item=$_POST['item'];
$cantidad=$_POST['cantidad'];
$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="<?=$PHP_SELF."?".$SID?>" 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="Añadir 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 'Artículo: '.$k.' ud: '.$v.'<br>';
}
}
?>
</tt>
</body>
</html>


pues eso si alguien sabe como hacerlo!!!


lee los objetos que hay:

foreach($itemsEnCesta as $k => $v){
echo 'Artículo: '.$k.' ud: '.$v.' DELETE<br>';

y quiero que cuando cliquen en delete se borre el objeto deseado y los demas sigan en la lista.


gracias.

pd: gran invento este de forosdelweb.