我创建了一个 php 文件来检索每个用户对他们的数据库数据的权限。代码将其显示为下拉框。下面的代码用于检索和显示它。
//session_start();
include('db.php');
//include('../CheckSession.php');
$userid=$_SESSION['UserID'];
echo'<ul class="dropdown"><li><a href="index.php">Home</a></li>';
$sql = "select privilege.privilege_catagory from privilege inner join user_privilege on privilege.privilege_id=user_privilege.privilege_id where user_privilege.UserID=$userid group by privilege.privilege_catagory ";
$result= mysql_query($sql) or die(mysql_error());
$num_row=mysql_num_rows($result);
if($num_row!=0)
{
while($rb=mysql_fetch_array($result))
{
$p_cat=$rb['privilege_catagory'];
echo'<li><a href="#">'.$p_cat.'</a>';
$sql2 = "SELECT privilege.url_Location,privilege.option_Name FROM privilege inner join user_privilege on privilege.privilege_id=user_privilege.privilege_id WHERE privilege.privilege_catagory='$p_cat' AND user_privilege.UserID=$userid" ;
//$sql2 = "SELECT privilege.url_Location,privilege.option_Name FROM privilege inner join user_privilege on privilege.privilege_id=user_privilege.privilege_id WHERE user_privilege.UserID =$userid";
$result2= mysql_query($sql2) or die(mysql_error());
$num_row2=mysql_num_rows($result2);
if($num_row2!=0)
{
echo'<ul class="sub_menu">';
while($rb2=mysql_fetch_array($result2))
{
echo'<li><a href="'.$rb2['url_Location'].'">'.$rb2['option_Name'].'</a></li>';
}
echo'</ul>';
}
echo'</li> ';
}
mysql_free_result($result);
}
else
{
}
echo'</ul>';
?>
Db 表如下:-
privilege_id
, privilege_name
, privilege_catagory
, url_Location
, option_Name
(这是在下拉菜单中显示的内容)
我在 index.page 中包含了这个 php 页面。那里一切正常。但是当页面重定向到任何其他页面时,下拉的 url 与当前 url 连接,例如,当我重定向到 localhost/demo/index.php 到 localhost/demo/Admission/NewAdmission.php 它可以工作
但是当我从那里点击主页('index.php'是url值)时,它会转到:localhost/demo/Admission/index.php!
有趣的。但我遇到了严重的麻烦。所有的关注都受到热烈欢迎。提前致谢。