![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
01/03/2004, 15:02
|
| | Fecha de Ingreso: febrero-2004 Ubicación: Chillán
Mensajes: 35
Antigüedad: 21 años Puntos: 0 | |
Explicacion de este codigo hola Maestros, quisiera saber si alguien puede ver este código y explicarlo en forma detallada. Yo algo entiendo(bien poco de verdad). Donde se esta guardando el nombre del producto?
<?php
session_start();
session_register('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;
}
}
?>
<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> |