leo76uk
18 Jul 2010, 07:13 PM
Hi everyone,
I am creating a shopping cart using cookies. The item is post method form which can be $cart = $_REQUEST['item']. I am trying to create an array of requested items using
<?php
if ($cart) {
$cart .= ',' .$_REQUEST['item'];
} else {
$cart = $_REQUEST['item'];
}
setcookie( "product", $cart,time()+86400);
?>
But not able to retrieve data using the following so the get items from the database.
<?php
if ($cart) {
$items = explode(',',$cart);
foreach ($items as $item) {
echo $item;
}
}
?>
Can anybody give me the solutions?
I am creating a shopping cart using cookies. The item is post method form which can be $cart = $_REQUEST['item']. I am trying to create an array of requested items using
<?php
if ($cart) {
$cart .= ',' .$_REQUEST['item'];
} else {
$cart = $_REQUEST['item'];
}
setcookie( "product", $cart,time()+86400);
?>
But not able to retrieve data using the following so the get items from the database.
<?php
if ($cart) {
$items = explode(',',$cart);
foreach ($items as $item) {
echo $item;
}
}
?>
Can anybody give me the solutions?