Well ... almost
I can have more than 9 quantity fields.
See my sample code.
Change $size array to XS, S, M, L, XL, XXL. Now we have 18 quantity fields.

I need get attributes/properties from db and make a grid with these values.
I know how many attributes I have ( 2 - color and size ) but I dont know how many properties each attribute have ( can be S, M, L or XS, S, M, L, XL, XXL or 7, 8, 9, 10, 11 or ... )
-------------
Good job for estimator