Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/02/2010, 01:41
futbolregional
 
Fecha de Ingreso: agosto-2008
Mensajes: 71
Antigüedad: 15 años, 8 meses
Puntos: 2
Problema tienda

Buenas estoy haciendo una pruebas para aprender y comprender como funciona el tema de las tiendas online para montar una, he conseguido un codigo que he modificado a mi gusto mas o menos, ademas de conseguir que se vacie el carro, el problema lo encuentro cuando quiero eliminar una insercion, he intentado varias cosas pero no lo consigo, alguien podria echar una mano....

Les dejo el codigo...

[HIGHLIGHT="PHP"]<?php
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;
?>[/HIGHLIGHT
Código HTML:
Ver original
  1. ]<html>
  2. <tt>
  3. <form action="<?=$PHP_SELF."?".$SID?>" method="post">
  4. Dime el producto <input type="text" name="item" size="20"><br>
  5. Cuantas unidades <input type="text" name="cantidad" size="20"><br>
  6. <input type="submit" value="Añadir a la cesta"><br>
  7. </form>
  8. </tt>
  9. <p><tt>
Código PHP:
Ver original
  1. <?
  2. if (isset($itemsEnCesta)){
  3.     echo'El contenido de la cesta de la compra es:<br>';
  4.     foreach($itemsEnCesta as $k => $v){
  5.         echo '<a href="borrararticulo.php?id='.$k.'">Artículo: '.$k.' ud: '.$v.'<br></a>';
  6.     }
  7. }
  8. ?>
Código HTML:
Ver original
  1. </tt></p>
  2. <p><a href="borrar.php">Borrar Carrito</a></p>
  3. </body>
  4. </html>

En el enlace de borrararticulo es donde intento recoger el indice para despues eliminarlo, pero no consigo acertar que codigo he de poner....

Un saludo
__________________
Hasta otra.... porque seguro que habrá otra....