Re: Unlimited Categories
| From: | Micah Stevens | Date: | Tue, 14 Jan 2003 05:45:15 +0000 |
| Subject: | Re: Unlimited Categories | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24821@lists.php.net to get a copy of this message | ||
Use the parent/child relationship thing:
CREATE TABLE Categories (
CategoryID int(11) NOT NULL auto_increment,
ParentID int(11) NOT NULL default '0',
Category_Name tinytext NOT NULL,
PRIMARY KEY (CategoryID)
) TYPE=MyISAM;
So at each level you can find the subcategories by:
SELECT * FROM Category WHERE ParentID = $This_Level_ID;
The top level would have a ParentID of 0.
*shrug* - One way to do it.
-Micah
On Mon, 2003-01-13 at 21:32, Gerard Samuel wrote:
> Im figuring this is more of an sql question than anything else.
> I'm trying to figure out a table structure to create unlimited depths of
> categorical data.
> I've done something for category/subcategories before, but haven't an
> idea how to create categories at an unlimited depth.
>
> Any pointers would be greatly appreciated.
> Thanks
>
> --
> Gerard Samuel
> http://www.trini0.org:81/
> http://dev.trini0.org:81/
--
Raincross Technologies
Development and Consulting Services
http://www.raincross-tech.com