1 Star 0 Fork 32

Admin/家谱familytree

forked from jiehu0992/家谱familytree 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ostype.php 2.13 KB
一键复制 编辑 原始数据 按行查看 历史
jiehu0992 提交于 2018-08-17 22:32 . 欧式版式家谱数据样式文档
<?php
include("conn.php");//数据库连接
$array=array();
$sql=mysql_query("select * from tree_lr");
while ($row=mysql_fetch_array($sql)){
$array[]=$row; //查出数据保存到数组中
}
//后台左侧循环树形栏目
function lefttree(){
global $array; //设置全局变量
$tree = array();
$categorylist="";
if( $array ){
foreach ( $array as $v ){
//$pt = $v['pid'];
$pt = $v['pid'];
$list = @$tree[$pt] ? $tree[$pt] : array();
array_push( $list, $v );
$tree[$pt] = $list;
}
}
if(is_array($tree[0])){
$i = 0;
foreach($tree[0] as $k=>$v){
$i++;
if($tree[$v["id"]]){
$categorylist.="
<div class=\"level top_line\"><div class=\"level_name\">第".$v["dc"]."世代</div>
<div class=\"member\">
<div style=\"\" class=\"member_name\">".$v["name"]."</div>
<div class=\"member_desc\">".$v["info"]."</div> </div>
</div>";
$categorylist.="\n";
$categorylist.=sonTree($tree[$v["id"]],$tree,0,$type);
}else{
if($v["is_link"]==0){
$categorylist.=" ".$v["name"]." ".$v["info"]." </div>";
}
}
}
}
return $categorylist;
}
function sonTree($arr,$tree,$level,$type){
$level++;
$ii=0;
foreach($arr as $k2=>$v2){
$ii++;
if($tree[$v2["id"]]){
$categorylist.="<div class=\"level top_line\"><div class=\"level_name\">第".$v2["dc"]."世代</div>
<div class=\"member\">
<div style=\"\" class=\"member_name\">".$v2["name"]."</div>
<div class=\"member_desc\">".$v2["info"]."</div>
</div> </div> ";
$categorylist.=" \n";
$categorylist.=sonTree($tree[$v2["id"]],$tree,$level,$type);
}else{
if($v["is_link"]==0){
$categorylist.="<div class=\"level top_line\"> <div class=\"level_name\">第".$v2["dc"]."世代</div>
<div class=\"member\">
<div style=\"\" class=\"member_name\">".$v2["name"]."</div>
<div class=\"member_desc\">".$v["info"]."</div>
</div> </div> ";
$categorylist.="\n";
}
}
}
return $categorylist;
}
$menu=lefttree();//调用函数
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/yaant_admin/genealogy_familytree.git
git@gitee.com:yaant_admin/genealogy_familytree.git
yaant_admin
genealogy_familytree
家谱familytree
master

搜索帮助