The best way is to use a database with a table simular to
cat_name, this_uid, parent_uid
then you can put entries into it such as
food, 1, 0
fruit, 2, 1
apple, 3, 2
apple, 4, 2
bread, 5, 1
cars, 6, 0
ford, 7, 6
escort, 8, 7
fiat, 9, 6
then you can pull back all the entries with a zero parent id these are the top level then search for all the entires with a parent id that matches the 'this_id' for each entry.
something like
<PRE>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<?
require_once("/usr/local/apache/includes/mysql_database.inc");
show_sub(0, 0);
function show_sub($parent_id, $indent)
{
$this_struct=new mysql_dbase("struct");
$this_struct->connect();
$query="select * from struct where parent_uid like '".$parent_id."'";
$retval=$this_struct->do_query($query, "y");
if ( $retval > 0 )
{
while ( $fields=$this_struct->get_data() )
{
for ( $loop=0; $loop<$indent; $loop++ )
{
echo " ";
}
echo $fields['cat_name']."<BR>";
show_sub($fields['this_uid'], ($indent+1));
}
}
}
?>
</BODY>
This uses one of my own classes to handle the
database stuff but you should be able to get
the idea. The display is a little basic
but again you should be able to make up your
own layout.
Mark.