Hi, i’m having a small puzzle problem i can’t seem to solve and was hoping someone here could help me with.
The problem is as following:
I have a mysql database that looks like this:
table1(table) | table2(column) | table3(column) | table4(column)
tablename1 | 1 | 0 | 0 (values)
table2(table) | table1(column) | table3(column) | table4(column)
tablename2 | 0 | 1 | 1 (values)
table3(table) | table1(column) | table2(column) | table4(column)
tablename3 | 0 | 0 | 1 (values)
table4(table) | table1(column) | table2(column) | table3(column)
tablename3 | 0 | 0 | 1 (values)
what i want to achieve is to generate a tree like this:
tablename1 - tablename2 - tablename3
- tablename4 - tablename3
The way i’m trying to make this work goes a bit like this:
check all columns of tablename1
foreach column with value 1 from tablename1
{ echo tablename(s) of column (tablename2)
check all columns of tablename2
foreach column with value 1 from tablename2
{ echo tablename(s) of column (tablename3 & tablename4)
...etc
and this ofcourse does only work for the amount of times i include extra lines to check, but because i have no idear how deep these trees go, i need a way to loop this.
i hope someone can point me in the right direction. tnx in advance.