MySQL/PHP Iterative Tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, I've been racking my brain trying to figure this one out, so
I thought I'd post the question here and see who bytes. =)

I have a table:

id INTEGER, PRIMARY KEY
parentid INTEGER DEFAULT (0)
name VARCHAR(32) NOT NULL

Ok, and I am using this structure to make a kind of drill down
structure, so the top level would be where parentid = '0', then
you take those id's and select from this table where parentid is
equal to those id's, and now your starting to navigate through
the tree, and so on.

Now, the real question, I have found a Javascript menu script which
will let users of the site click on it, and then click on the submenu
and down and down through all the level's that might dynamically exist,
but I can't for the life of me figure out how to recursively get the
name and id for each row (which is what I need to build the menu and
make link's out of each item), for as many sublevel's as there might be
(infinite). Am I missing something, is there a simple logical way to do
this recursively? Or if there's a semi-complex way, anyone got a script
example? I'd very much appreciate it.

-- 
Adam Voigt (adam@cryptocomm.com)
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux