Subject: Re: [PHP-DB] Unlimited Categories
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
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 *
EG:
CREATE TABLE category (
id int not null auto_increment,
parent int default 0,
name varchar 100,
);
The parent field contains the ID of the record of which category it belongs.
Then use a recursive function to display the 'levels' of data. (If parent is
0 then it is top level category)