incrediBILL - 3:47 am on Jan 28, 2013 (gmt 0)
You need 2 databases to easily accomplish this, products and options. You simply query all the options for that product and display them in a drop down box. Options need to be identified by product ID and option group so you can create a size group, color group, etc.
That's a simplistic implementation.
Learning and rolling your own cart is fun, but why not just get a free pre-built cart that has all the options you want already built and tested?
FWIW, many web hosting accounts offer a cart already installed on the server.