gpt4 book ai didi

php - 使用 PHP 在每个用户权限的基础上向 MySQL 数据库中的用户显示菜单项?

转载 作者:可可西里 更新时间:2023-11-01 06:44:47 25 4
gpt4 key购买 nike

我有一个用于 users 的 MySQL 数据库表和一个新的 menu links .使用 PHP,更具体地说,我也在使用 Laravel。

我需要构建一个用户菜单,在每个用户权限的基础上显示菜单项。

通常这是使用 user groups 完成的但是我的要求是基于每个用户构建它!

这意味着每个菜单项都需要有一个 yesno为数据库中的每个用户保存在某处的值。

然后我需要向每个用户显示这个菜单,只显示他们允许查看的菜单项。

我有下面的用户和链接 MySQL 数据库架构。

我需要帮助的是,我相信我需要添加另一个第三张表 user_link_permissions它将存储每个用户和菜单项的设置,以确定用户是否可以查看菜单项。

我不确定如何构建 PHP 以仅显示允许用户查看的菜单项,并且还可以使用一些帮助来了解第 3 个表可能需要的样子吗?

我处理了将构建菜单 HTML 输出的 PHP 代码,我认为最好有一种方法来检查循环中的每个菜单项记录以查看当前用户是否有权查看它。 .. 例子

// Array of menu items from MySQL Database or even just a MySQL result?
$menuItems = array();

foreach ($menuItems as $key => $value) {

// can cureent user view this menu item record or not?
if($this->user->canViewMenuItem($value)){
// show menu item
}

}

用户表
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(160) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`first_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`last_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`address_street` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`address_city` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`address_state` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`address_postal_code` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`address_country` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'USA',
`job_position` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`user_role` enum('admin','manager','employee') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'employee',
`payday_group` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`default_user_photo_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_user_photo_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_date` datetime NOT NULL,
`last_login_date` datetime DEFAULT NULL,
`updated_date` datetime DEFAULT NULL,
`login_counter` bigint(20) NOT NULL DEFAULT '0',
`total_time_worked` bigint(20) DEFAULT NULL,
`user_notes` text COLLATE utf8_unicode_ci,
`time_zone` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'US/Central',
`clocked_in` tinyint(1) NOT NULL DEFAULT '0',
`status` tinyint(1) NOT NULL DEFAULT '1',
`webcam` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`user_id`),
UNIQUE KEY `users_username_unique` (`username`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=64 ;

友情链接表
CREATE TABLE IF NOT EXISTS `intranet_links` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`description` text NOT NULL,
`url` varchar(255) DEFAULT NULL,
`permission` varchar(50) NOT NULL DEFAULT 'admin',
`notes` text,
`active` int(2) NOT NULL DEFAULT '1',
`sort_order` int(11) DEFAULT NULL,
`parent_id` int(10) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

为了让事情稍微复杂一点,我的菜单也将具有像类别/文件夹/目录这样的层次结构。这样 1 个菜单项就可以有子菜单项 o 我的实际菜单输出如下图所示,除了每个菜单项也将根据每个用户的权限设置显示或不显示!

enter image description here

现在我的问题只是关于如何构建第三个数据库表,然后如何查询和显示每个用户的正确链接。在该部分完成后,虽然我还会有一个设置页面,其中每个菜单项都可以设置为 yes/no对于数据库中的每个用户。类似于这个 SugarCRM 权限页面...除了顶部的水平列是 links并且垂直记录将是用户....

enter image description here

最佳答案

将您的权限设为整数,并为每个菜单项或按权限分组的菜单项使用 1 位。

然后使用一点明智的 AND 来确定权限是否匹配。

用户和链接都有一个权限列。

权限是一个整数

权限 A = 1
权限 B = 2
权限 C = 4
权限 D = 8
权限 E = 16
权限 F = 32

如果 B 组和 D 组都显示菜单项,则:

如果 (link_permission & user_permission) 不为零,则用户具有权限。

如果只有 B 和 D,链接权限的值为:
权限 B + 权限 D,或 2+8 (00000010 + 00001000) = 00001010(十进制,A 十六进制)

现在,如果用户的权限 = 2 (0010) 或用户的权限 = 8 (1000)
当与链接权限 00001010 进行 AND 运算时,用户权限和链接权限的位与结果不会为零(非零 = 真时为真)。

define('LINK_PERMISSION_ACCESS' ,1);  // 000000001
define('LINK_PERMISSION_DELETE' ,2) ; // 000000010
define('LINK_PERMISSION_EDIT' ,4) ; // 000000100
define('LINK_PERMISSION_EXPORT' ,8) ; // 000001000
define('LINK_PERMISSION_IMPORT',16) ; // 000010000
define('LINK_PERMISSION_UPDATE',32) ; // 000100000
define('LINK_PERMISSION_VIEW' ,64) ; // 001000000

$linkPermission = LINK_PERMISSION_B + LINK_PERMISSION_D; // 0010 + 01000

$userPermission = LINK_PERMISSION_D; // 01000

您也可以定义组级别值
define('LINK_PERMISSION_ADMIN' ,255); // 11111111

您可以定义多个权限

我将使用十六进制而不是十进制,否则数字将无法管理
define('LINK_PERMISSION_ACCOUNTS'  ,0x8000); 
define('LINK_PERMISSION_AUDIT' ,0x4000);
define('LINK_PERMISSION_WORKFLOW' ,0x2000);
define('LINK_PERMISSION_BUGTRACKER',0x1000);

只有帐户访问权限的用户将是
`user.permission` = LINK_PERMISSION_ACCOUNTS + LINK_PERMISSION_ACCESS ;

具有帐户访问、编辑和删除权限的用户将是
`user.permission` = LINK_PERMISSION_ACCOUNTS 
+ LINK_PERMISSION_ACCESS
+ LINK_PERMISSION_DELETE
+ LINK_PERMISSION_EDIT;

如果您需要每个区域的用户权限列:
CREATE TABLE IF NOT EXISTS `user` (
...
`accountPermission` int(11) NOT NULL DEFAULT '0',
`workFlowPermission` int(11) NOT NULL DEFAULT '0',
`contactsPermission` int(11) NOT NULL DEFAULT '0',
`campaignPermission` int(11) NOT NULL DEFAULT '0',

但如果权限数为 4 或更少,例如:
define('LINK_PERMISSION_ACCESS' ,1);  // 000000001
define('LINK_PERMISSION_DELETE' ,2) ; // 000000010
define('LINK_PERMISSION_EDIT' ,4) ; // 000000100
define('LINK_PERMISSION_VIEW' ,8) ; // 000001000

`permission` int(11) NOT NULL DEFAULT '0',

其中帐户、工作流、联系人和事件分为 4 位:
account  workflow  contacts campaign
0000 0000 0000 0000

PERMISSION_ACCOUNT_ACCESS, 0x1000
PERMISSION_WORKFLOW_ACCESS, 0x0100
PERMISSION_CONTACTS_ACCESS, 0x0010
PERMISSION_CAMPAIGN_ACCESS, 0x0001

PERMISSION_ACCOUNT_DELETE, 0x2000
PERMISSION_WORKFLOW_DELETE, 0x0200
PERMISSION_CONTACTS_DELETE, 0x0020
PERMISSION_CAMPAIGN_DELETE, 0x0002

PERMISSION_ACCOUNT_EDIT, 0x4000
PERMISSION_WORKFLOW_EDIT, 0x0400
PERMISSION_CONTACTS_EDIT, 0x0040
PERMISSION_CAMPAIGN_EDIT, 0x0004

PERMISSION_ACCOUNT_VIEW, 0x8000
PERMISSION_WORKFLOW_VIEW, 0x0800
PERMISSION_CONTACTS_VIEW, 0x0080
PERMISSION_CAMPAIGN_VIEW, 0x0008

回到您的链接

定义常量
define ('SERVER_ADMIN',2);
define ('UBUNTU_DASHBOARD',4);
define ('REDIS_CACHE_ADMIN',8);
define ('MYSQL_DB_MANAGEMENT',16);
define ('NEON_AND_MORE',32);
define ('NEON_AND_MORE_(NAM)',64);
define ('SUGARCRM',128);
define ('NAM_MAGENTO_ADMIN',256);
define ('NAM_TIME_CLOCK',512);
define ('NEONANDMORE_BLOG_ADMIN',1024);
define ('ORDER_REPORTS',2048);
define ('WORK_ORDERS',4096);
define ('UPDATE_ORDER_STATUS',8192);
define ('CHANNEL_LETTER',16384);
define ('CHANNEL_LETTER',32768);
define ('MAGENTO_ADMIN',65536);
define ('BORDER_TUBING',131072);
define ('BORDER_TUBING',262144);
define ('SIGN_PARTS_AND_MORE',524288);
define ('SIGN_PARTS_AND_MORE',1048576);
define ('OTHER_SERVICES',2097152);
define ('PUSHER_REALTIME_EVENTS',4194304);
define ('ZOPIM_CUSTOMER_SUPPORT_CHAT',8388608);
define ('GOOGLE_ANALYTICS',16777216);
define ('GITLAB_(PRIVATE_GITHUB_CLONE)',33554432);
define ('LABS_/_PROJECTS',67108864);
define ('NAM_LABS',134217728);
define ('CAMERA_PHONE',268435456);
define ('SERVER_EMAIL_VERIFICATION',536870912);

链接和用户都有一个权限列:
`permissions` int(11) NOT NULL DEFAULT '0',

define('LINK_PERMISSION_ACCOUNTS' ,0x8000);
define('LINK_PERMISSION_AUDIT' ,0x4000);
define('LINK_PERMISSION_WORKFLOW' ,0x2000);
define('LINK_PERMISSION_BUGTRACKER',0x1000);

如果用户具有帐户和错误跟踪器访问权限:
$userPermission = LINK_PERMISSION_ACCOUNTS + LINK_PERMISSION_BUGTRACKER;
UPDATE `users` SET `permissions`= $userPermission WHERE `id` = $user

然后是所需的链接权限:
$linkPermission = LINK_PERMISSION_ACCOUNTS;

我们对具有用户权限的链接权限进行了有点明智的 AND (&)
SELECT * FROM `links` WHERE (`permissions` & $userPermission) 

链接是否为子菜单链接无关紧要

这是典型的分层表:
CREATE TABLE IF NOT EXISTS `links` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent` int(11) NOT NULL DEFAULT '0',
`sort` int(11) NOT NULL DEFAULT '0',
`text` char(32) COLLATE utf8_bin NOT NULL,
`link` text COLLATE utf8_bin NOT NULL,
`permission` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

相反,我们可以消除、父和排序,id 列将完成所有工作。

2 级菜单结构:主菜单和子菜单,'id' 被分解

菜单子(monad)菜单

菜单编号为 0x0100 到 0xFF00

子菜单编号为 0x0002 到 0x00FE

对于此菜单:

enter image description here

创建链接表的 SQL:
CREATE TABLE IF NOT EXISTS `links` (
`id` int(11) NOT NULL,
`text` char(64) COLLATE utf8_bin NOT NULL,
`link` text COLLATE utf8_bin NOT NULL,
`permission` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO `links` (`id`, `text`, `link`, `permission`) VALUES
(512, 'Server Admin', '#', 1),
(514, 'Ubuntu Dashboard', '#', 2),
(518, 'Redis Cache Admin', '#', 4),
(522, 'MySQL dB Management', '#', 8),
(1024, 'Neon and More', '#', 16),
(1026, 'Neon and More (NAM)', '#', 32),
(1030, 'SugarCRM', '#', 64),
(1034, 'NAM Magento Admin', '#', 128),
(1038, 'NAM Time Clock', '#', 256),
(1042, 'NeonAndMore Blog Admin', '#', 512),
(1046, 'Order Reports', '#', 1024),
(1050, 'Work Orders', '#', 2048),
(1054, 'Update Order Status', '#', 4096),
(1536, 'Channel Letter', '#', 8192),
(1538, 'Channel Letter', '#', 16384),
(1542, 'Magento Admin', '#', 32768),
(2048, 'Border Tubing', '#', 65536),
(2050, 'Border Tubing', '#', 131072),
(2560, 'Sign Parts And More', '#', 262144),
(2562, 'Sign Parts And More', '#', 524288),
(3072, 'Other Services', '#', 1048576),
(3074, 'Pusher Realtime Events<br/>Instant Caller ID Alerts', '#', 2097152),
(3078, 'Zopim Customer Support Chat', '#', 4194304),
(3082, 'Google Analytics', '#', 8388608),
(3086, 'GitLab (Private GitHub Clone)', '#', 16777216),
(3584, 'Labs / Projects', '#', 33554432),
(3586, 'NAM LABS', '#', 67108864),
(3590, 'Camera Phone', '#', 134217728),
(3594, 'Server Email Verification', '#', 268435456);

现在为链接菜单创建 HTML:

SQL
SELECT `id`, `text`, `link`, `permission` 
FROM `links`
WHERE (`permission` & $userpermission )

PHP

头部和 CSS
<?php 
ob_start("ob_gzhandler");
header('Content-Type: text/html; charset=utf-8');
header('Connection: Keep-Alive');
header('Keep-Alive: timeout=5, max=100');
header('Cache-Control: max-age=84600');
header('Vary: Accept-Encoding');
echo <<<EOT
<!DOCTYPE html>
<html lang="en"><head><title>Daily Rx</title><meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style type="text/css">
.submenu,.mainmenu{text-align:left;border-radius: 3px 3px 3px 3px;font: 700 1.1em Arial,Helvetica,Calibri,sans-serif;overflow: visible;}
.submenu{border:1px solid #0f0;color: #fff;margin:.2em 0 .2em .8em;width:16.8em;padding: 0 0 0 .8em;
background-image: -o-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -moz-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -webkit-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -ms-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: linear-gradient(to bottom, #3d5 0%, #370 100%);}
.mainmenu{font-size:1.2em;margin:.2em .2em .2em .2em ;width:16em;padding-left:1em;border:1px solid #00f;color: #fff;
background-image: -o-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -moz-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -webkit-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -ms-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: linear-gradient(to bottom, #2ef 0%, #02f 100%);}
.hide{display:none;}
#x{height:40em;}
#page{margin:0;padding:0;}
hr{font-size:.1em;padding:0;margin:0 0 0 1em;width:50em;opacity:0;}
</style></head><body><div id="page">
EOT;
ob_flush();

创建菜单
$userpermission = 4294967295; // 0xffffffff
$sql = "SELECT `id`, `text`, `link`, `permission` FROM `links` WHERE (`permission` & $userpermission ) > 0";
$results = mysqli_query($conn,$sql);
if (mysqli_errno($conn) > 0){echo mysqli_error($conn) . "<br>\n$sql\n";}
while($row = mysqli_fetch_array($results, MYSQL_NUM)){
$class = $row[0] & 1;
if($class == 0){
$i++;
echo "$closeSubmenu\n<button class=\"mainmenu\" onclick=\"show($i)\">$row[1]</button>\n<div class=\"hide\" id=\"d$i\">\n";
}
else{
echo "<form action=\"$row[2]\"><div><input type=\"hidden\" name=\"user\" value=\"$user\" /><input type=\"hidden\" name=\"id\" value=\"$row[0]\" /><input type=\"hidden\" name=\"permission\" value=\"$userpermission\" /><button class=\"submenu\">$row[1]</button></div></form>\n";
}
$closeSubmenu = '</div><hr/>';
}

用于扩展和收缩子菜单的 JavaScript
ob_flush();
echo <<<EOT
</div><div id="x"><p>&#x2003;</p></div>
<script type="text/javascript">
//<![CDATA[
var toggle = new Array();
toggle[''] ='block';
toggle['none'] ='block';
toggle['block'] ='none';
var div,disp;
var prev = document.getElementById('d1');
prev.style.display='none';
function show(id){
div = document.getElementById('d' + id);
disp = div.style.display;
prev.style.display='none';
div.style.display=toggle[disp];
prev=div;
var y=div.offsetTop;
window.scrollTo(0, y-32);
}
//]]>
</script></div></body></html>
EOT;
ob_end_flush();
?>

快速页面加载,仅需 132 毫秒

这个 PHP 页面在浏览器中加载只需 100 多毫秒。
这只是到 TPC/IP 连接所需的时间。

HTML 从服务器传输到浏览器的时间仅为 2 毫秒。

下图来自 http://www.webpagetest.org

enter image description here
DNS Lookup: 20 ms
Initial Connection: 35 ms
Time to First Byte: 95 ms
Content Download: 2 ms

W3C MobileOK Checker 分数:100%

W3C mobileOK Checker

你不会找到很多可以做到这一点的网页:

enter image description here

Google PageSpeed Insights 100% 移动和桌面速度和可用性

Google PageSpeed Insights

enter image description here

enter image description here

片段

此代码段是使用上面的 PHP 制作的,并将查看源粘贴到此处:

var toggle = new Array();
toggle[''] ='block';
toggle['none'] ='block';
toggle['block'] ='none';
var div,disp;
var prev = document.getElementById('x');
function show(id){
div = document.getElementById('d' + id);
disp = div.style.display;
prev.style.display='none';
div.style.display=toggle[disp];
prev=div;
var y=div.offsetTop;
window.scrollTo(0, y-32); }
.submenu,.mainmenu{text-align:left;border-radius: 3px 3px 3px 3px;font: 700 1.1em Arial,Helvetica,Calibri,sans-serif;overflow: visible;}
.submenu{border:1px solid #0f0;color: #fff;margin:.2em 0 .2em .8em;width:16.8em;padding: 0 0 0 .8em;
background-image: -o-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -moz-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -webkit-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: -ms-linear-gradient(bottom, #3d5 0%, #370 100%);
background-image: linear-gradient(to bottom, #3d5 0%, #370 100%);}
.mainmenu{font-size:1.2em;margin:.2em .2em .2em .2em ;width:16em;padding-left:1em;border:1px solid #00f;color: #fff;
background-image: -o-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -moz-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -webkit-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -ms-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: linear-gradient(to bottom, #2ef 0%, #02f 100%);}
.hide{display:none;}
#x{height:40em;}
#page{margin:0;padding:0;}
hr{font-size:.1em;padding:0;margin:0 0 0 1em;width:50em;opacity:0;}
<div id="page">
<button class="mainmenu" onclick="show(1)">Server Admin</button>
<div class="hide" id="d1">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="257" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Ubuntu Dashboard</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="259" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Redis Cache Admin</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="261" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">MySQL dB Management</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(2)">Neon and More</button>
<div class="hide" id="d2">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="513" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Neon and More (NAM)</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="515" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">SugarCRM</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="517" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">NAM Magento Admin</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="519" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">NAM Time Clock</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="521" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">NeonAndMore Blog Admin</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="523" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Order Reports</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="525" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Work Orders</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="527" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Update Order Status</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(3)">Channel Letter</button>
<div class="hide" id="d3">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="769" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Channel Letter</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="771" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Magento Admin</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(4)">Border Tubing</button>
<div class="hide" id="d4">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1025" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Border Tubing</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(5)">Sign Parts And More</button>
<div class="hide" id="d5">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1281" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Sign Parts And More</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(6)">Other Services</button>
<div class="hide" id="d6">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1537" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Pusher Realtime Events<br/>Instant Caller ID Alerts</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1539" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Zopim Customer Support Chat</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1541" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Google Analytics</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1543" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">GitLab (Private GitHub Clone)</button></div></form>
</div><hr/>
<button class="mainmenu" onclick="show(7)">Labs / Projects</button>
<div class="hide" id="d7">
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1793" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">NAM LABS</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1795" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Camera Phone</button></div></form>
<form action="#"><div><input type="hidden" name="user" value="123" /><input type="hidden" name="id" value="1797" /><input type="hidden" name="permission" value="4294967295" /><button class="submenu">Server Email Verification</button></div></form>
</div><div id="x"><p>&#x2003;</p></div>

关于php - 使用 PHP 在每个用户权限的基础上向 MySQL 数据库中的用户显示菜单项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29830336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com