R
Rob Meade
Hi all,
Ok - so I've got the array thing going on, and the session thing going on,
and up until now its all been ok.
I've got my view basket page which is displaying 3 rows (as an example) - I
have an input box on each row enabling the user to update the quantity.
If the enter a zero I need to remove the item from the array....
Without getting too much into code - I was hoping for an "in words" reply as
to how to get around my problem...
I have 2 loops - one outer, one inner, which are iterating through 2 arrays,
the outer array is that of the "quantities" as posted by the form, the inner
array is that of the items in the basket as populated from the session.
Now - I've tried implementing my code that removes items from the array, but
I've discovered a problem....because I need to remove the item I end up
using a temporary array to store the items that are NOT being removed, then
I resize the original array and pop 'em back in. Because the size of the
original array has now changed, if there are more than one item in the
basket which are being removed (by entering a zero for quantity) when it
gets to the next zero to deal with, the index has changed on the array -
thus buggering my loops a tad...
Any thoughts/theories on the approach to this - again, ideally in words
rather than code - its late and my eyes hurt
(
Thanks in advance for any help.
Regards
Rob
Ok - so I've got the array thing going on, and the session thing going on,
and up until now its all been ok.
I've got my view basket page which is displaying 3 rows (as an example) - I
have an input box on each row enabling the user to update the quantity.
If the enter a zero I need to remove the item from the array....
Without getting too much into code - I was hoping for an "in words" reply as
to how to get around my problem...
I have 2 loops - one outer, one inner, which are iterating through 2 arrays,
the outer array is that of the "quantities" as posted by the form, the inner
array is that of the items in the basket as populated from the session.
Now - I've tried implementing my code that removes items from the array, but
I've discovered a problem....because I need to remove the item I end up
using a temporary array to store the items that are NOT being removed, then
I resize the original array and pop 'em back in. Because the size of the
original array has now changed, if there are more than one item in the
basket which are being removed (by entering a zero for quantity) when it
gets to the next zero to deal with, the index has changed on the array -
thus buggering my loops a tad...
Any thoughts/theories on the approach to this - again, ideally in words
rather than code - its late and my eyes hurt
Thanks in advance for any help.
Regards
Rob