  
  
     <ul class="treeview-menu">
                                <!-- Submodule from a module here query -->
                                <?php     $stmt1 = $conn->query(" SELECT * FROM  sys_sub_module  a where a.module= '".$sub["id"]."' and active=1   ");
                                    foreach($stmt1  as $P)
                                            {  ?>
                                                  <li class="treeview">
                                                        <!-- Submodule listing -->
                                                        <a href="<?php echo $P["url"]; ?>">   <?php echo $P["icon"]?> <span> <?php echo $P["name"]; ?> </span> <i class="fa fa-angle-left pull-right"></i> </a>
                                                        <ul class="treeview-menu">
                                                            <!--page Query based on submodule -->
                                                            <?php    $stmt3 = $conn->query(" SELECT a.*,b.role  FROM  sys_page a left join sys_rights b  on a.id= b.page
                                                                                                        where a.submodule= '".$P["id"]."'   and a.active=1 and b.role= '$role' order by displayno asc    ");
                                                                foreach($stmt3  as $PAGE)
                                                                      {  ?>
                                                                           <!-- Page Listing -->
                                                                            <li class=""><a href='<?php echo $PAGE["url"];?>'><?php echo $PAGE["icon"]; ?> <?php echo $PAGE["name"]; ?></a></li>  
                                                                 <?php } ?>        
                                                        </ul>
                                                    </li>
                                    <?php } ?>        
                          </ul>

    <ul class="treeview-menu">
            <!-- Submodule from a module here query -->
            <?php $stmt1 = $conn->query(" SELECT * FROM  sys_sub_module  a where a.module= '".$sub["id"]."' and active=1   ");
                foreach($stmt1  as $SBM)
                        {  ?>
                                <li class="treeview">
                                    <!-- Submodule listing -->
                                    <a href="<?php echo $SBM["url"]; ?>">   <?php echo $SBM["icon"]?> <span> <?php echo $SBM["name"]; ?> </span> <i class="fa fa-angle-left pull-right"></i> </a>
                                    <!-- CHILD QUERY -->
                                        <ul class="treeview-menu">
                                                <!-- Submodule child  from a submodule here query -->
                                                <?php     $stmt1 = $conn->query(" SELECT * FROM  sys_submodulechild  a where a.submodule= '".$SBM["id"]."' and active=1   ");
                                                    foreach($stmt2  as $CH)
                                                            {  ?>
                                                                <li class="treeview">
                                                                        <!-- Submodule listing -->
                                                                        <a href="<?php echo $CH["url"]; ?>">   <?php echo $CH["icon"]?> <span> <?php echo $CH["name"]; ?> </span> <i class="fa fa-angle-left pull-right"></i> </a>
                                                                        <ul class="treeview-menu">
                                                                            <!--page Query based on submodule -->
                                                                            <?php    $stmt3 = $conn->query(" SELECT *  FROM  sys_page a  where a.submodulechild= '".$CH["id"]."'   and a.active=1    ");
                                                                                foreach($stmt3  as $PAGE)
                                                                                    {  ?>
                                                                                        <!-- Page Listing -->
                                                                                            <li class=""><a href='<?php echo $PAGE["url"];?>'><?php echo $PAGE["icon"]; ?> <?php echo $PAGE["name"]; ?></a></li>  
                                                                                <?php } ?>        
                                                                        </ul>
                                                                    </li>
                                                    <?php } ?>        
                                        </ul>
                                    <!-- Child Query -->
                                    
                                </li>
                <?php } ?>        
        </ul>