Re: session_name("CCLTrolley")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is that over kill? No matter how I slam it, still referring to my Frankensteinian merge, "unset" does the job.
http://testesp.flsh.usherbrooke.ca/db/trolley.php
But then again, I will not require a quanity of items. The visitor will only want one copy of a bibliographic entry :-\ - I hope?! You were checking to see if there was a greater than 1 quantity of post[RNum], right?
Thanks,
John

   //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']] );
   #    }
   }

Robert Cummings wrote:

Thanks for your time and patience,
John
The expression:
   $trolley[$item] -= $quantity;
is a short form for the following:
   $trolley[$item] = $trolley[$item] - $quantity;
Essentially we decrease the quantity of the given item by $quantity.
if( $trolley[$item] < 1 )
{
#Above we check if we subtracted more items than is physically possible
unset( $trolley[$item] );
#If there are 0 or less items then there's no point having 0 of the item
#in the trolley, so we unset the item from the array, which essentially
#removes it completely. To view the difference at each step you can do
#the following:

<?php

if( isset( $trolley[$item] ) )
{
   echo "Trolley before removing $quantity of $item<br />";
   trolleyPrint();

   $trolley[$item] -= $quantity;

   echo "Trolley after removing $quantity of $item<br />";
   trolleyPrint();

   if( $trolley[$item] < 1 )
   {
       unset( $trolley[$item] );

       echo "Trolley after cleaning up empty entry for $item<br />";
       trolleyPrint();
   }
}

?>

Cheers,
Rob.

--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."

 ' ' '    Collège de Sherbrooke:
ô¿ô    http://www.collegesherbrooke.qc.ca/languesmodernes/
   -     819-569-2064

 °v°   Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\  Université de Sherbrooke
 ^ ^   http://compcanlit.ca/ T: 819.569.2064


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux