>This is the old version I demonstrated. You should go with the later
>version that sets the values to the quantity :)
I thought I had? Haven't I?
But this is the easiest shopping cart I have ever seen.
However, I still have not understood what you were doing with these
lines I commented out.
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
They did not work, or seem to?
John
---------------snip--------------------
http://testesp.flsh.usherbrooke.ca/db/trolley.php
Array
(
[TrolleyContents] => Array
(
[2378] => 2378
[2504] => 2504
)
)
)
---------------snip--------------------
<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
$_SESSION['TrolleyContents'] = array();
}
echo $_POST['ShopAction']."!!<br>";
if("add" == $_POST['ShopAction'])
{
echo "adding ...";
// Add new entry:
if( isset( $_POST['RNum'] ) )
{
$_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
#echo $_POST['RNum']."!!<br>";
}else{
echo "deleting ...";
//Delete an entry:
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
}
}
print_r( $_SESSION );
?>
--------Delete form: snip -------
<form ACTION="trolley.php" METHOD="POST">
<input type="hidden" name="RNum" value="2378">
<input type="hidden" name="searchenquiry" value="Taylor-Johnston,
John"><input type="hidden" name="ShopAction" value="delete">
<input type="image" name="submit" src="/icon/full3.gif" border="0"
alt="Delete" title="Delete" style="padding-right:
5px;"><br><small>Delete</small></form>
--------Add form: snip -------
<form targt="printwindow" ACTION="trolley.php" METHOD="POST">
<input type="hidden" name="RNum" value="2504">
<input type="hidden" name="searchenquiry" value="John
Taylor-Johnston"><input type="hidden" name="ShopAction" value="add">
<input type="image" name="submit" src="/icon/empty3.gif" border="0"
alt="Add to cart" title="Add to cart" style="padding-right:
5px;"><br><small>Add to cart</small></form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php