I am new to PHP (coming from ASP) and am looking for some help in working on a tool I started to write in ASP but didn't get working quite right.
I have a database that contains an id (primary key), a parent id, and a data entry for that id.
What I need to do build a hierarchical tree showing the tree structure, and display the group totals of each "branch" of the tree.
For instance, I have a parent, two children, and 3 subchildren for each child. say each entry has a value of 10 (they all vary, however).. the parent would have a group value of 90, with each child haivng a group value of 40 each, and the subchild having group values of 10 each.
I need to display the tree structure, and the totals for their group as they're generated.
-parent 90 10
-child 40 10
-child1 10 10
-child2 10 10
-child3 10 10
-child 40 10
-child1 10 10
-child2 10 10
-child3 10 10
I built the tree in asp using recursive database calls, allowing for "unlimited" depth and width of the tree, but it opened a lot of database connections to do it. I'll deal with peformance if I need to do this again, but am not sure how to calculate the group values dynamically.
Any thoughts? I appreciate all the help I can get on this, sample code, etc.
Thanks,
John