<nav id="menu" class="navbar main-menu rounded-0">
  <div class="container">
    <div class="navbar-header"><span id="category" class="visible-xs">Categories</span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav" style="text-transform: uppercase;">
        <li class="dropdown">
          <a href="index">Home</a>
        </li>
        <?php
        $sql  = mysqli_query($conn,"SELECT * FROM main_cat ORDER BY id ASC");
        while($row = mysqli_fetch_array($sql)){
          $menu = $row['id'];
          ?>
          <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $row['name']; ?></a> 
            <div class="dropdown-menu" style="min-width: 450px">
              <div class="dropdown-inner">               
                <ul class="list-unstyled">
                  <div class="row col-lg-12">
                    <?php
                    $sql_cat  = mysqli_query($conn,"SELECT
                      sub_cat_mapping.sub_cat_name,sub_cat_mapping.sub_cat
                      FROM
                      cat
                      Inner Join sub_cat_mapping ON cat.cat_id = sub_cat_mapping.main_cat
                      Inner Join sub_cat ON sub_cat_mapping.sub_cat = sub_cat.sub_cat_id
                      WHERE
                      cat.menu_id = $menu");
                    while($row_cat = mysqli_fetch_array($sql_cat)){
                     ?>
                     
                     <div class="col-lg-6 col-xs-12">
                       <li><a href="home?cid=<?php echo $row_cat['sub_cat']; ?>"><?php echo $row_cat['sub_cat_name']; ?></a></li></div>
                     <?php } ?>
                   </div>
                 </ul> 
               </div>
             </div>
           </li>
         <?php } ?>
       </ul>
     </div>
   </div>
 </nav>