-
全路径无限分类原理查看全部
-
123查看全部
-
无限极分类下拉列表案例查看全部
-
递归无限分类原理查看全部
-
递归实现技巧查看全部
-
無限級分類 1、已父ID实现的无限分类 2、以全路径实现的无限分类(用一個字段記錄所有子分類id)查看全部
-
下拉列表:SELECT *,IF(path,CONCAT(path,',',id),id) AS fullpath FROM likecate ORDER BY fullpath; 面包屑(按path排序): SELECT *,IF(path,CONCAT(path,',',id),id) AS fullpath FROM likecate WHERE id=10; SELECT * FROM likecate WHERE id IN (1,2,3,10) ORDER BY path; SELECT *,IF(path,CONCAT(path,',',id),id) AS fullpath FROM likecate WHERE id=14; SELECT * FROM likecate WHERE id IN (12,11,14) ORDER BY path;查看全部
-
CREATE TABLE likecate ( id INT UNSIGNED NOT NULL PRIMARY KEY, path VARCHAR(200) NOT NULL DEFAULT '' COMMENT '全路径', catename VARCHAR(30) NOT NULL DEFAULT '' COMMENT '分类名', cateorder INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序', createtime INT UNSIGNED NOT NULL COMMENT '创建时间' )ENGINE=MYISAM DEFAULT CHARSET=utf8; INSERT INTO likecate VALUES (1,'','手机',0,0), (2,'1','功能手机',0,0), (3,'1,2','老人手机',0,0), (4,'1,2','儿童手机',0,0), (5,'1','智能手机',0,0), (6,'1,5','Android手机',0,0), (7,'1,5','iOS手机',0,0), (8,'1,5','winphoto手机',0,0), (9,'1,2,4','色盲手机',0,0), (10,'1,2,3','大字手机',0,0), (11,'12','台式机',0,0), (12,'','电脑',0,0),/*经过一些增删操作,有可能父类id大于子类id*/ (13,'12,11','一体机',0,0), (14,'12,11','非一体机',0,0), (15,'12','笔记本',0,0);查看全部
-
抄别人的笔记,因为采集的笔记“只看我的”的时候不显示 递归的三种方式:&引用符 全局变量global 静态变量 static (竟然引用时可以不用到参数) CREATE TABLE IF NOT EXISTS `deepcate` ( `id` int(4) NOT NULL, `pid` int(11) NOT NULL, `catename` varchar(30) NOT NULL, `cateorder` int(11) unsigned NOT NULL DEFAULT '0', `createtime` int(10) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='cms类型表'; -- -- 转存表中的数据 `deepcate` -- INSERT INTO `deepcate` (`id`, `pid`, `catename`, `cateorder`, `createtime`) VALUES (1, 0, '新闻', 0, 0), (2, 0, '图片', 0, 0), (3, 1, '国内新闻', 0, 0), (4, 1, '国际新闻', 0, 0), (5, 3, '北京新闻', 0, 0), (6, 4, '美国新闻', 0, 0), (7, 2, '美女图片', 0, 0), (8, 2, '风景图片', 0, 0), (9, 7, '日韩明星', 0, 0), (10, 9, '日本AV', 0, 0);查看全部
-
递归是个循环查看全部
-
无限分类的例子查看全部
-
无限极分类代码 <?php include('connect.php'); header("Content-type: text/html; charset=utf-8"); function getList($pid=0,&$result=array(),$spac=0){ $spac = $spac + 2; $sql = "SELECT * FROM deepcate WHERE pid=$pid"; $res = @mysql_query($sql); while($row = mysql_fetch_assoc($res)){ $row['catename'] = str_repeat(' ',$spac).'|--'.$row['catename']; $result[] = $row; getList($row['id'],$result,$spac); } return $result; } function displayCate($pid=0,$selected=1){ $rs = getList($pid); $str=''; $str.= "<select name='cate'>"; foreach($rs as $key => $val){ $selectedstr = ''; if($val['id'] == $selected){ $sellectedstr ="selected"; } $str.= "<option {$selectedstr}>{$val['catename']}</option>"; } return $str .= '</select>'; } echo displayCate(0,1); ?>查看全部
-
CREATE TABLE IF NOT EXISTS `deepcate` ( `id` int(4) NOT NULL, `pid` int(11) NOT NULL, `catename` varchar(30) NOT NULL, `cateorder` int(11) unsigned NOT NULL DEFAULT '0', `createtime` int(10) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='cms类型表'; -- -- 转存表中的数据 `deepcate` -- INSERT INTO `deepcate` (`id`, `pid`, `catename`, `cateorder`, `createtime`) VALUES (1, 0, '新闻', 0, 0), (2, 0, '图片', 0, 0), (3, 1, '国内新闻', 0, 0), (4, 1, '国际新闻', 0, 0), (5, 3, '北京新闻', 0, 0), (6, 4, '美国新闻', 0, 0), (7, 2, '美女图片', 0, 0), (8, 2, '风景图片', 0, 0), (9, 7, '日韩明星', 0, 0), (10, 9, '日本AV', 0, 0);查看全部
-
分类应用查看全部
-
无限极分类递归形式查看全部
举报
0/150
提交
取消