Recursive infinite classification notes
Recently, projects have been launched to consolidate php knowledge every day. The following is a comparison of recursive infinite classification for your reference!
Database a table on it, add a parendid field that is sub-classification, sorting we can also add fields.
CREATE TABLE `roomy` (`id` int (11) NOT NULL, `name` varchar (255) CHARACTER SET utf8 DEFAULT NULL, `sort_ order` int (11) DEFAULT NULL, `parendid` int (11) DEFAULT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB DEFAULT CHARSET=latin1 -Records of category-- INSERT INTO `roomy` VALUES ('1mm,' mobile phone', null,'0'); INSERT INTO `roomy` VALUES ('2mm,' home appliances', null,'0') INSERT INTO `roomy`VALUES ('3million,' Furniture', null,'0'); INSERT INTO `roomy`VALUES ('4million,' Nokia', null,'1'); INSERT INTO `roomy`VALUES ('5', 'Apple', null,'1'); INSERT INTO `roomy`VALUES ('6', 'refrigerator', null,'2'); INSERT INTO `roomy`VALUES ('74th,' TV', null,'2') INSERT INTO `roomy` VALUES ('880,' cabinet', null,'3'); INSERT INTO `roomy` VALUES ('999,' table', null,'3'); INSERT INTO `roomy`VALUES ('10mm,' Nokia 3310mm, null,'4'); INSERT INTO `roomy`VALUES ('111mm,' Apple 8slots, null,'5'); INSERT INTO `roomy`VALUES ('1250,' Haier refrigerator', null,'6') INSERT INTO `roomy` VALUES ('1300,' Changhong TV', null,'7'); INSERT INTO `roomy`VALUES ('1400,' mahogany cabinet', null,'8'); INSERT INTO `roomy`VALUES ('15mm,' mahogany table', null,'9')
Php code section