Re: MySQL/PHP Iterative Tree

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello Adam

On 26 November 2002 at 08:25:22 -0500 (which was 13:25 where I live) Adam
Voigt emanated these words of wisdom

< ... >

> 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,

Be careful of the size and the time it takes to build a big tree.

> 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.

This is not much help but have done something like that in MSSQL with stored
procedure (about 120 to 150 lines of SQL).

The logic went something like.

get all top level
put into a temptable_1
go through temptable_1
  put line into temptable_2 noting level
  add on any children for line into temptable_2
next line of temptable_1
copy temptable_2 to temptable_1
keep going through temptable_1 until there is no more children at last level

I also used a separate table for the links this way it is easier to go both
up and down the tree.

What would be nice is to do it dynamically and display only the tree that
you need and just get the data for the children when needed. eg like MSDSon
M$ site

- --
 TTFN,                     _______________________________________________
  David                   |    David  Elliott    |   Software Engineer    |
 _________________________| david@elliott.uk.com | PGP Key ID 0x650F4534  |
| I am Barney of Borg...Sesame Street will be assimilated.                |

-----BEGIN PGP SIGNATURE-----
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPeOIC/mK8eZlD0U0EQI8YQCdEKtpYBkVNmLGYEs2xt3RKBoh1A0An2FG
KzmAxhrABe/7JZxw3mvmYkaJ
=xdTm
-----END PGP SIGNATURE-----


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

  Powered by Linux