Are you using a session to store the stuff in the cart or what? I'd suggest creating a session for the user with the following variables:
array $quantity
array $product
each element of those arrays will contain the info for an item. ($quantity[0] has the quantity of the first item and $product[0] has the name or item number or id of the product).