> Hi,
> I want to make a recursive function generating a hierarchy using a class.
>
> The following code works fine when I don't wrap the function around it,
> but when I do it fails. I can't figure out why...
> I'm thinking I may need to make some vars global, or maybe you can't use
> objects inside functions? (No, couldn't be)
If following code is all code that you make a tree node. Your guess is rgiht.
Take a look at
http://www.php.net/manual/en/language.variables.scope.php
You also better to read reference section carefully (espacially you have been
programminged in C/C++)
http://www.php.net/manual/en/language.references.php
regards,
Yasuo Ohgaki
>
> Here's the code:
> .........
> $root = $tree->open_tree ($title, "");
>
> function generate_nodes($id) {
>
> $sql = "select * from hierarchy where parent = $id";
> $res = mysql_debug_query($sql);
> while ($row = mysql_fetch_array($res)) {
> $node = "node" . $count;
> $$node = $tree->add_folder ($root, $row["name"] . " <font
> size=1>" . $row["id"] . "</font>", "");
>
> $count++;
> }
> }
> generate_nodes($id);
> ........
> Thanks for any hints...
> Peter
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> http://liga1.com: building multiple language/culture websites
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]