MariaDB [gnbdmap]> select id,parent_id,name,url from admin_menu;
+----+-----------+----------------------+----------------------+
| id | parent_id | name | url
+----+-----------+----------------------+----------------------+
| 1 | 0 | 회원관리 | MemberList.php
| 2 | 0 | 빌딩 기본 정보 | bldList.php
| 3 | 0 | 빌딩 층별 정보 | FloorHo.php
| 4 | 0 | KOS 월 정보 | bldKOSData.php
| 5 | 0 | 빌딩 고객 현황 | Customer.php
| 6 | 0 | 업종분류 | TypeofBusiness.php
| 8 | 0 | 접속IP관리 | IPaddr.php
| 9 | 0 | 앱버전 | AppManage.php
| 10 | 0 | 직위관리 | PositionMN.php
| 11 | 0 | 업로드 | UploadMemberData.php
| 12 | 0 | 접속이력 | AccessLogList.php
| 13 | 0 | 관리이력 | ManagerLogList.php
| 14 | 0 | 비정상접속 | AuthError.php
| 15 | 0 | 카카오지도 | kmap.php
+----+-----------+----------------------+----------------------+
$res = $d->getDbresult("admin_menu", "", "id,parent_id,name,url");
foreach($res as $row){
$sidemenu[ ] = $row;
}
$side_menu = bootstrap4_sideMenu($sidemenu);
echo $side_menu;
function bootstrap4_sideMenu($array, $parent_id = 0, $parents = array())
{
$menu_html = ' ';
$menu_html .= '<ul class="collapsible collapsible-accordion" id = "sidemenu">';
if(isset($_SESSION['authID']) && $_SESSION['authID'] == 1)
$menu_html .= '<li><a href="#" id="adminMenu"><i class= "far fa-address-book"></i>메뉴관리</a></li>'
//누구냐에 따라 메뉴가 보였다 안보였다
foreach($array as $element){
if($element['parent_id']== $parent_id && in_array($element['id'], $parents)){ // 서브메뉴 만들기
$url = $element['url'];
$menu_html .= '<li><a class="collapsible-header waves-effect arror-r" href="'.$url''> <i class="fa-hand-pointer-o">';
$menu_html .= '</i>' .$element['name'].'<i class="fas fa-angle-down rotate-icon"></i></a>';
$Sub_item = SubTree($element['id'];
foreach($Sub_item as $item) {
$sub_url = $item['url'];
$menu_html .= '<a class="waves-effect" href="'.$sub_url.'">'.$item['name'].'</a>';
}
} else if($element['parent_id']== $parent_id){
$url = $element['url'];
$menu_html .= '<li class = "nav-item">';
$menu_html .= '<a class="nav-link" href="' .$url. '">'.$element['name'].'</a>';
}
return $menu_html;
}
}