大家来看下这样的权限树怎么实现?谢谢 考虑这种思路:一个函数负责生成树型目录数组然后直接显示这个数组的内容即可实际上,这种数据结构不好,如果在ORACLE中,可以考虑这种结构本级机构ID 上级机构ID 机构其它信息显示时用connect子句就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是我写的代码,存在问题,望高手帮忙改正...(感觉思路一开始就是错误的,呵呵)//树的生成算法(非递归算法)生成父节点$root_node;获得所有的对象列表$currentNode;for($i=0;$i<count($currentNode);){ //获得当前对象$currentNode的父对象编码 $fathercode=substr($currentNode[$i]['classcode'],0,(strlen($currentNode[$i]['classcode'])-3)); if(父对象编码为空){ //以$root_node为父节点生成该节点; $fatherNode=creatNode($text,$link,$currentNode,$root_node); for($j=$i+1;$j<count($currentNode);$j++){ $fatherCode=substr($currentNode[$j]['classcode'],0,(strlen($currentNode[$j]['classcode'])-3)); $len=strlen($fatherCode); if(strcmp(substr($currentNode[$j]['classcode'],0,$len),$fatherCode))==0){ //保留父指针 $nextNode=$fatherNode; //生成节点的指针 $fatherNode=creatObj($text,$link,$childNode, $nextNode); } else{ //如果不是是同级节点 if(strlen($currentNode[$j]['classcode'])!=strlen($currentNode[$j-1]['classcode'])){ $nextNode--; } else{ //同级节点 $next=$fatherNode; $fatherNode(creatObj($text,$link,$childNode,$nextNode); } } } } //树的生成算法(非递归算法)生成菜单对象$menu;//生成"权限管理"父节点;$topNode="node";$$topNode=&menu->additem($text,$link,$current_node);获得所有的对象列表$currentNode;for($i=0;$i<count($currentNode);$i++){ $fathercode=substr($currentNode[$i]['classcode'],0,(strlen($currentNode[$i]['classcode'])-3)); //计算父节点名称; $parnetNode=trim("node".$fathercode); $prefix_node="node".$current[$i]['classcode']; $$prefix_node=&$$parentNode->additem($text,$link,$currentNode);} 请教javascript如何获取PHP字符串类型数组的值? 把数据库查出的数据放入到数组里 php如何访问object div的问题 大牛: mysql升级时字符串乱码的问题 用php操作文件的问题。文件大概有100M,有什么比较高效的方法? 这样写是引用还是复制.... 临时表加limit的分页问题 php+mysql+数据库的使用--个简单的聊天室学习程序,结果经过一下午的调试,终于出世,可又问题多多..... 我的MYSQL就是运行不了啊请问怎样解决?谢谢 (急!!!)关于url的长度 get参数的个数 get参数的值的长度 关于php中对mysql进行insert,update等操作
//树的生成算法(非递归算法)生成父节点$root_node;获得所有的对象列表$currentNode;for($i=0;$i<count($currentNode);){
//获得当前对象$currentNode的父对象编码
$fathercode=substr($currentNode[$i]['classcode'],0,(strlen($currentNode[$i]['classcode'])-3));
if(父对象编码为空){
//以$root_node为父节点生成该节点;
$fatherNode=creatNode($text,$link,$currentNode,$root_node); for($j=$i+1;$j<count($currentNode);$j++){
$fatherCode=substr($currentNode[$j]['classcode'],0,(strlen($currentNode[$j]['classcode'])-3));
$len=strlen($fatherCode);
if(strcmp(substr($currentNode[$j]['classcode'],0,$len),$fatherCode))==0){
//保留父指针
$nextNode=$fatherNode;
//生成节点的指针
$fatherNode=creatObj($text,$link,$childNode, $nextNode);
}
else{
//如果不是是同级节点
if(strlen($currentNode[$j]['classcode'])!=strlen($currentNode[$j-1]['classcode'])){
$nextNode--;
}
else{ //同级节点
$next=$fatherNode;
$fatherNode(creatObj($text,$link,$childNode,$nextNode);
} }
}
}
生成菜单对象$menu;//生成"权限管理"父节点;
$topNode="node";
$$topNode=&menu->additem($text,$link,$current_node);获得所有的对象列表$currentNode;for($i=0;$i<count($currentNode);$i++){
$fathercode=substr($currentNode[$i]['classcode'],0,(strlen($currentNode[$i]['classcode'])-3));
//计算父节点名称;
$parnetNode=trim("node".$fathercode);
$prefix_node="node".$current[$i]['classcode'];
$$prefix_node=&$$parentNode->additem($text,$link,$currentNode);
}