sorting a "tree"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

sorting a "tree"

Post by pelegk2 »

for example i have a bug "TREE" in my DB
that's its final result look''s like this :
http://www.mattkruse.com/javascript/mktree/
now i my DB i hold rows like this


quote:
--------------------------------------------------------------------------------


node_id | parent_id | name(text)
------------------------------------


--------------------------------------------------------------------------------


now when i pull the data from the table like :
"select * from tables tree"
i recive a record set with all the rows in the DB!
now i want to send to the client the correct structre of the tree including it's subtitles,and the subtitles of the subtitles and so on
.....
what is the best way to build a structured array or what ever so the final tree will look like the one in the example?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply