Hi
I have a table with something like
ID PARENT
0 | -1
1 | -1
2 | 1
3 | 1
4 | 2
5 | -1
6 | 4
And i want to build an array so i can output the data in the form
0
1
|--2
|----4
| |----5
|--3
5
Where 2 is a child of 1, and 4 is a child of 2 and so on.
I could create an array like $data[$id][$parent] but how would i output the
data where i get all the children of, say, ID=1 and all the children of ID =
4.
What would be the best way to achieve the above using MySQL db and php?
If i read all the data sorted by PARENT i might be able to read the whole
table at once and add all the data to one array?
Any ideas?
Regards.
Simon/
I have a table with something like
ID PARENT
0 | -1
1 | -1
2 | 1
3 | 1
4 | 2
5 | -1
6 | 4
And i want to build an array so i can output the data in the form
0
1
|--2
|----4
| |----5
|--3
5
Where 2 is a child of 1, and 4 is a child of 2 and so on.
I could create an array like $data[$id][$parent] but how would i output the
data where i get all the children of, say, ID=1 and all the children of ID =
4.
What would be the best way to achieve the above using MySQL db and php?
If i read all the data sorted by PARENT i might be able to read the whole
table at once and add all the data to one array?
Any ideas?
Regards.
Simon/
Comment