I'm trying to organize information extracted from the database
basically, it works like a forum
there is the main element
and feedbacks to the elements
However, elements can have unspecified number of children
and it is built like a pyramid system
my problem is I need to nest children under parents.
To make things worse. I dont want to do queries for each element to look for children in DB's
So what I did is create a table in MySql like so
Element ID | Parent ID | and info about the element |
element's Parent Id's are simply the ElementID's of their parents
if elements have no parents, PARENTID = 0 and they go on the root
MAIN THING
--Element 1
----Child 1
----Child 2
----Child 4
----- Child 6
----- Child 7
---- Child 8
--Element 2
----Child
--Element 3
-- Child 1
--Element 4
and so fourth..
I've tried going about this with arrays but i cant seem to grast my head around it.
I want to do 1 query, and simply organize them in such a way that they nest
I know it's possible because I've seen it done before.
Any ideas or suggestions?
thank,
rulian