求无限级的PHP树形菜单代码,还有菜单要可以执行。
1个回答
展开全部
jquery支持
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function() {
$('#tree').lightTreeview({
collapse: true,
line: true,
nodeEvent: true,
unique: true,
style: 'black',
animate: 400
});
});
</script>
2.树菜单函数
<?
function getCategoryTree($TID, $iTable,$url,$urlPar="1=1") {
if ($TID == 0) {
$treeStr = $treeStr."<ul id=\"tree\" class=\"lightTreeview treeview-black\">";
}
$sql = "select * from `$iTable` where TID1 = ".$TID." order by orderid";
$rs = mysql_query($sql);
while ($ary = mysql_fetch_array($rs)) {
$treeStr = $treeStr."<li>";
$rs2 = mysql_query("select count(*) from `$iTable` where TID1 = ".$ary["id"]);
$Vcount = @mysql_result($rs2, 0);
if ($Vcount != 0) {
$treeStr = $treeStr."<div class=\"treeview-folder\">".$ary["title"]."</div><ul style=\"display:none\">";
$treeStr = $treeStr.getCategoryTree($ary["id"], $iTable,$url,$urlPar);
$treeStr = $treeStr."</ul>";
} else {
$treeStr = $treeStr."<div class=\"treeview-file\"><a href=\"".$url."?T=".$ary["id"]."&".$urlPar."\" target=\"pro\">".$ary["title"]."</a></div>";
}
$treeStr = $treeStr."</li>";
}@mysql_free_result($rs);
if ($TID == 0) {
$treeStr = $treeStr."</ul>";
}
return $treeStr;
}
?>
3.页面上调用
<div>
<?=getCategoryTree(0,"N_type","edit.php","1=1")?>
</div>
4.数据结构
id title TID1(上一级ID)
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function() {
$('#tree').lightTreeview({
collapse: true,
line: true,
nodeEvent: true,
unique: true,
style: 'black',
animate: 400
});
});
</script>
2.树菜单函数
<?
function getCategoryTree($TID, $iTable,$url,$urlPar="1=1") {
if ($TID == 0) {
$treeStr = $treeStr."<ul id=\"tree\" class=\"lightTreeview treeview-black\">";
}
$sql = "select * from `$iTable` where TID1 = ".$TID." order by orderid";
$rs = mysql_query($sql);
while ($ary = mysql_fetch_array($rs)) {
$treeStr = $treeStr."<li>";
$rs2 = mysql_query("select count(*) from `$iTable` where TID1 = ".$ary["id"]);
$Vcount = @mysql_result($rs2, 0);
if ($Vcount != 0) {
$treeStr = $treeStr."<div class=\"treeview-folder\">".$ary["title"]."</div><ul style=\"display:none\">";
$treeStr = $treeStr.getCategoryTree($ary["id"], $iTable,$url,$urlPar);
$treeStr = $treeStr."</ul>";
} else {
$treeStr = $treeStr."<div class=\"treeview-file\"><a href=\"".$url."?T=".$ary["id"]."&".$urlPar."\" target=\"pro\">".$ary["title"]."</a></div>";
}
$treeStr = $treeStr."</li>";
}@mysql_free_result($rs);
if ($TID == 0) {
$treeStr = $treeStr."</ul>";
}
return $treeStr;
}
?>
3.页面上调用
<div>
<?=getCategoryTree(0,"N_type","edit.php","1=1")?>
</div>
4.数据结构
id title TID1(上一级ID)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询