$strquery = "SELECT A.role_id,B.page_id,C.parent_page
FROM system_user_role_tbl AS A
INNER JOIN system_page_role_tbl AS B
ON A.role_id = B.role_id
AND B.rec_status = 1
INNER JOIN system_page_tbl AS C
ON C.page_id = B.page_id
AND C.rec_status=1
AND A.user_id = '1f5443f497b7e955ffde9d83863f5868'
AND A.rec_status = 1
group by B.page_id";
$result = mysql_query($strquery);
$num = mysql_num_fields($result);
$r=0;
while($data =mysql_fetch_row($result)){
$res[$r] = getmenu($data[1]);
$r++;
}
foreach($res as $value)
{
$page = split(",",$value);
if(count($page) == 1)
{
echo "<div style='width:100px;float:left;border:solid;'>";
echo "<div style='padding-right:5px;'>".$page[0]."</div>";
echo "</div>";
}else{
echo "<div style='width:100px;float:left;border:solid;'>";
for($n=count($page)-1;$n>-1;$n--)
{
echo "<div style='padding-right:5px;''>".$page[$n]."</div>";
}
echo "</div>";
}
}
function getmenu($pageid){
$strquery = "SELECT A.role_id,B.page_id,C.parent_page
FROM system_user_role_tbl AS A
INNER JOIN system_page_role_tbl AS B
ON A.role_id = B.role_id
AND B.rec_status = 1
INNER JOIN system_page_tbl AS C
ON C.page_id = B.page_id
AND C.page_id = '".$pageid."'
AND C.rec_status=1
AND A.rec_status = 1
group by B.page_id";
$result = mysql_query($strquery);
while($data =mysql_fetch_row($result)){
if($data[2] != NULL){
return $data[1].",".getmenu($data[2]);
}else{
return $data[1];
}
}
}