...

View Full Version : learning to make tree



darksecu
07-28-2012, 12:47 PM
i am looking to make a tree structure of users.

this is how my members table looks
id - username - few more columns - sponsor

i need to create a tree structure using 2 fields, id and sponsor ..

sponsor fields contains id of parent user. :p

Thanks,
Rahul

Fou-Lu
07-28-2012, 03:35 PM
Okay, and your question is what?
Trees are written with either recursion or loop trickery, or you can write a tree or directional graph datastructure and iterate it using breadth first. In either case dumping the data from a query into an array or datastructure is a lot easier to work with than an active resultset.

darksecu
07-28-2012, 04:50 PM
Okay, and your question is what?
Trees are written with either recursion or loop trickery, or you can write a tree or directional graph datastructure and iterate it using breadth first. In either case dumping the data from a query into an array or datastructure is a lot easier to work with than an active resultset.

sample code that can do my work :o

Fou-Lu
07-28-2012, 07:28 PM
sample code that can do my work :o

Then google up for a PHP tree. I'm sure there are a lot of examples for using tree datastructures, graphs and recursive or iterative building of a tree.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum