...给小弟一个 php 简单的树形菜单 代码! 要注释。。非常感谢!!!_百度...
发布网友
发布时间:2024-09-17 03:28
我来回答
共1个回答
热心网友
时间:2024-09-29 09:15
要看效果,你加Q:573780643
1.jquery支持
<script type="text/javascript" src="http://www.shkl.cc/common/javaScript/jquery-1.4.min.js"></script>
<script type="text/javascript" src="http://www.shkl.cc/common/javaScript/lightTreeview/jquery.lightTreeview.pack.js"></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)
热心网友
时间:2024-09-29 09:14
要看效果,你加Q:573780643
1.jquery支持
<script type="text/javascript" src="http://www.shkl.cc/common/javaScript/jquery-1.4.min.js"></script>
<script type="text/javascript" src="http://www.shkl.cc/common/javaScript/lightTreeview/jquery.lightTreeview.pack.js"></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)