Re: Unlimited categories

From: Date: Sat, 12 Mar 2005 05:53:31 +0000
Subject: Re: Unlimited categories
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-210582@lists.php.net to get a copy of this message
Popescu Dan wrote:
Hi, I have a database table withe the next fields: category_id, parent_id, category_name. How can i display all the categories with their subcategories, like this Category 1 Category 11 Category 12
     Category121
Category 2 Category 21 Category 22
You need to use a function that lists the children of the passed parent_id, then call it recursively so that it prints a tree. For the initial call, you would pass it the root id, usually 0 or -1. There is a great Sitepoint article that details how to do this. Read http://www.sitepoint.com/article/hierarchical-data-database

« previous php.general (#210582) next »