imho the example on 
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
(scroll down to "The Nested Set Model") is much better than the
sitepoint tutorial. it also gives you detailed examples how to add and
remove nodes and branches from the tree.

however, some select queries are not exactly right:

SELECT node.name, (COUNT(parent.name) - 1) AS depth
FROM nested_category AS node,
nested_category AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name
ORDER BY node.lft;

instead you should always group by node.id and not by node.name,
otherwise you get in trouble if your name is not unique.

try http://www.dhtmlx.com/docs/products/dhtmlxTree/index.shtml for a
js tree component. it also supports autoloading from xml.
i just couldnt figure out how to open the tree to a given position, so
everytime i reload the page all nodes are closed again :/


--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to