THINKPHP兄弟连李文凯老师视频笔记:15自动完成实现无限分类

15自动完成实现无限分类
volist的实用化
数据库的设计以避免需要使用递归

三种方式实现无限分类:
递归
ajax
亲戚关系(使用亲戚关系方式)
CREATE TABLE IF NOT EXISTS `think_cate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` char(30) NOT NULL,
`pid` int(11) NOT NULL,
`path` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;

INSERT INTO `think_cate` (`id`, `name`, `pid`, `path`) VALUES
(1, ‘新闻’, 0, ‘0’),
(2, ‘中国新闻’, 1, ‘0-1’),
(3, ‘美国新闻’, 1, ‘0-1’),
(4, ‘北京新闻’, 2, ‘0-1-2’),
(5, ‘华盛顿新闻’, 3, ‘0-1-3’),
(6, ‘海淀新闻’, 4, ‘0-1-2-4’),
(7, ‘上地新闻’, 6, ‘0-1-2-4-6’),
(8, ‘七街新闻’, 7, ‘0-1-2-4-6-7’),
(9, ‘9号楼新闻’, 8, ‘0-1-2-4-6-7-8’),
(11, ‘体育’, 0, ‘0’);

select id,name,pid,path,concat(path,’-‘,id) as bpath
from think_cate
order by bpath
(未解决问题,不能对栏目进行排序,不能三级联动)

Related posts:

Leave a Reply

Your email address will not be published.