2006-11-02

用PHP实现多级树型菜单

来源: aspcool 作者:佚名 评论 0 条
  //树型目录结构模板程序
//菜单目录库字段说明:
//menu_id 菜单项目 id
//menu 菜单名称
//menu_grade 菜单等级 1 为主菜单 2 为二级菜单 ........
//menu_superior 上一级菜单 id 号

function my_menu($menu_content,$i,$menu_grade_temp,$menu_superior_temp)
{
global $PHP_SELF;
$temp1=$menu_grade_temp 1;
$menu_superior_temp_array=split("/",$menu_superior_temp);
for ($t=0;$t<$i;$t )
{
$menu_array=split("/",$menu_content[$t]);
If(($menu_array[2]==$menu_grade_temp)&&($menu_array[3]==$menu_superior_temp_array[$menu_grade_temp-1]))
{
for($p=1;$p<=$menu_grade_temp;$p ){echo " ";}
$temp3=$menu_superior_temp_array;
$temp3[$menu_grade_temp]=$menu_array[0];
$temp2=implode("/",$temp3);
if ($menu_array[0]==$menu_superior_temp_array[$temp1-1])
{
$temp5=$temp1-1;
$temp3[$menu_grade_temp]="";
$temp6=implode("/",$temp3);
echo "$menu_array[1]
";

my_menu($menu_content,$i,$temp1,$temp2);
}
else
{
$temp3[$menu_grade_temp 1]="";
$temp6=implode("/",$temp3);
echo "$menu_array[1]
";

}
}
}
}
// 连接 MySql 数据库
$db_host="localhost";
$db_user="dkj";
$db_password="123";
$db_name="test";
mysql_connect($db_host,$db_user,$db_password);
mysql_select_db($db_name);

//从数据库中取得数据
$query_string="select * from menu order by menu_grade";
$db_data=mysql_query($query_string);
共2页: 上一页 1 [2] 下一页
(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:实用教程:编写基于PHP的聊天室  
下一篇:使用无限生命期Session的方法
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号