[英]Building a treeview
I'm trying to build an treeview but im totally stuck. 我正在尝试建立树视图,但我完全陷入困境。
Here's my table id int(11), 这是我的表ID int(11),
naam varchar(255), naam varchar(255),
parent int(11), 父int(11),
active int(11) 主动int(11)
Here the is the code (the data comes trough the class ContentCategory) 这是代码(数据来自ContentCategory类)
$ContentCategories = ContentCategory::getContentCategories();
<ul>
<?php
foreach ($ContentCategories as $ContentCategory) {
if ($ContentCategory->parent == 0){
?>
<li><?php echo $ContentCategory->naam?></li>
<?php
$parent_id = $ContentCategory->id;
}
if ($ContentCategory->id = $parent_id && $ContentCategory->parent !=0) {
echo "------".$ContentCategory->naam.'<br />';
$sparent_id = $ContentCategory->parent;
}
echo $sparent_id;
print_pre($ContentCategory);
}
?>
</ul>
This gives me the headcategories and the categories who are below it, now i'd like to get the next branches, it needs to be possible te make as many branches as i like. 这给了我标题和下面的类别,现在我想获得下一个分支,有必要尽可能多地创建分支。
But the problem is that i don't have a clue how to fix this. 但是问题是我不知道如何解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.