大概思路,
权限表: create table t_role ( roleid int, username varchar, roles text );
菜单表: create table t_menu( menuid int, name varchar );
//添加3个菜单
insert into t_meun (1, '菜单1');
insert into t_meun (2, '菜单2');
insert into t_meun (3, '菜单3');
//表示角色'张'有 菜单1 和 菜单2 两个访问功能
insert into t_role (1,'张', '菜单1|菜单2' );
<?php
// 张 登录了
$ret = mysql_query("select * from t_role where username='张'");
if ($row = mysql_fetch_array($ret)) {
$menus = explode('|',$row[roles]);
// 打印出 张 可以访问的菜单
foreach($menus as $menu) {
print("<tr><td>$menu<td><tr> <br/>");
}
}
?>