0

I have two tables in mysql: atributes and options.

Atributes

Id
Atribute

Options

Id
Idtribute
Option

Example atributes:

1, Size
2, Color
3, other
4, n...

Example options:

1, 1, S
2, 1, L
3, 1, M
4, 2, Red
5, 2, Green
6, 3, One
7, 3, Two
8, 3, Three
9, n, m

I want an string output like that:

S, Red, One
S, Red, Two
S, Red, Three
S, Green, One
S, Green, two
S, Green, three
L, Red, One
L, Red, Two
L, Red, Three
L, Green, One
S, Green, two
S, Green, three
etc.

I have tried with recursive functions, but I have not been able to do it. Somebody could help me? thx

1 Answers1

0

On PHP side you can assign the multi-dimensional array simply like so:

$array = new Array();

adding an element:

$array['element'] = element;

where element can also be an array.

On SQL-Site however, you should not (but could) save the array as a string, delimited by some character. You rather should follow the relational approach and save the atomic values each for it's own.

randmin
  • 818
  • 8
  • 16