CREATE TABLE `mptt` ( `id` int(11) NOT NULL auto_increment, `title` varchar(50) NOT NULL default '', `left` int(11) NOT NULL default '0', `right` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
-- -- Dumping data for table `mptt` --
INSERT INTO `mptt` VALUES (1, 'food', 1, 18); INSERT INTO `mptt` VALUES (2, 'fruit', 2, 11); INSERT INTO `mptt` VALUES (3, 'meat', 12, 17); INSERT INTO `mptt` VALUES (4, 'red', 3, 6); INSERT INTO `mptt` VALUES (5, 'yellow', 7, 10); INSERT INTO `mptt` VALUES (6, 'beef', 13, 14); INSERT INTO `mptt` VALUES (7, 'pork', 15, 16); INSERT INTO `mptt` VALUES (8, 'cherry', 4, 5); INSERT INTO `mptt` VALUES (9, 'banana', 8, 9);
Indentation
food fruit red cherry yellow banana meat beef pork
DISPLAYING
STEP 2: create php file called mptt.php with the following code:mptt.php
NOTE:CHANGE THE FOLLOWING TO YOUR DB CONNECTION SETTINGS:
HOSTNAME (usually localhost) USERNAME (your database username) PASSWORD (username password) DATABASE_NAME (the database where you dump mysql above)
this file will display all file in the FRUIT category OUTPUT:
yellow
cherry
banana