I have created a php file to retrieve the privileges of each user against their db data. And the code display it as a drop down box. The code below is used to retrieve and display it.
//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>';
?>
The Db Table is as below:-
privilege_id
, privilege_name
, privilege_catagory
, url_Location
, option_Name
(this is what to be displayed in drop down menu)
I include this php page in the index.page. Every thing works fine there. But when the page redirect to any other page the url of drop down is concatenate with the current url e.g. when i redirect to localhost/demo/index.php to localhost/demo/Admission/NewAdmission.php it works
but when i click on home('index.php' is the url value) from there it goes to : localhost/demo/Admission/index.php !!
Funny. But i am in serious trouble. All the attention is warm welcomed. Thanks in advance.