Generating stock levels of products with different options
===

I am building a cms for an online shop where the products can have upto 5 different options, which are size, colour, flavour, material and style. I need to create code to generate fields for the stock control records, which has to keep an individual record for each possible option, such as red size 8, blue size 8, red size nine striped etc. Here is my current db structure:

> Products
> -------
> Product ID

> Common values such as price, name and description

> Product Attributes
> ------------------
> Attribute ID

> Attribute Group ID

> Attribute Name

> Product Stock Control
> ---------------------
> Stock ID

> Product ID

> Attibute 1 ID

> Attibute 2 ID

> Attibute 3 ID

> Attibute 4 ID

> Attibute 5 ID

> Stock Level

Using codeigniter and php, what is the best way to code this?