I answered this in the last day or so, but received mail indicating that someone didn't quite follow the answer, so I'll take another stab at it.
First of all, model your data appropriately. A tree modeled very simply. It is a self-referential one-to-many relationship -- in other words, an object can have many children, but each child has only one parent.
CREATE TABLE foo (
objectid int(11) DEFAULT '0' NOT NULL auto_increment,
objectparent int(11),
title varchar(80),
description text
);
Now, make a root object
INSERT INTO foo SET title='I am a root', description='This object has an empty parentid';
Now query the database to retrieve the automatically assigned objectid for that object.
To create a "child" or branch from that object, INSERT (to create a new object) or UPDATE (to change an existing object) and set its parentid equal to the objectid of the parent node.
Now you have two objects "hooked together" by a parent-child relationship. You can set any number of objects to have an identical parent ID.
And any child can have its own children by applying the same principles.
Now you have data that represents the tree. The next problem is how to traverse the tree to print it out, et cetera.
This is actually quite simple. In PHP, issue a query to SELECT for all objects where parentid=0. That will give you the set of all root objects. (A system such as Yahoo's Web ontology will have a multiple root objects, as an example.)
For each retrieved item, query the database again to find all items whose parentid matches the currently examined objectid.
If you apply this rule recursively, you can dig down through a tree and print out the contents, et cetera.
If you want to see code that does exactly this, look at the sources for the message board system that I wrote, which you can get from stonemountain.yi.org.
In my message board database, I have containers called "rooms" that can hold other containers. This makes it fairly easy to have folders that contain folders, et cetera.