What you're describing is similar to how shopping carts work. A user goes to page, selects items A, B, C, etc. These items get added to the cart. Visitor goes to another part of the site and possibly removes an item, but then adds items D and E.
It might be easier for you just to search some PHP script repositories and look at the source code for shopping carts in order to model your code.
If you want to do it yourself, you could do it as follows:
- create an array.
- register the array in a $_SESSION variable.
- With each visit to a page in your site, check that the $_SESSION['array'] is set and maybe do a count of it if you want to display the number of items selected thus far.
- As a visitor selects items, use PHP functions to append values to the array kept in the session variable.
- When the visitor is done and wants to "check out" or display what he has selected thus far, you just use a foreach loop to echo out the values in the array.