
                                        <ul class="text-center">
                                          <?php
    // Main menu query
    $mainMenuAsk=$db->prepare("SELECT * FROM menu WHERE menu_top_id=:menu_top_id AND status=:status AND language=:language  ORDER BY order_sort");
    $mainMenuAsk->execute(array(
      'menu_top_id' => 0,
      'status'      => 1,
      'language'    => $getLangCheck['language_id']
    ));
    while($mainMenuCheck=$mainMenuAsk->fetch(PDO::FETCH_ASSOC)){
      // Does the main menu have a submenu?
      $countSubmenu=$db->prepare("SELECT * FROM menu WHERE menu_top_id=:menu_top_id AND status=:status ORDER BY order_sort");
      $countSubmenu->execute(array(
        'menu_top_id' => $mainMenuCheck['menu_id'],
        'status'      => 1
      ));
      $resultSubMenu=$countSubmenu->rowCount();
  ?>

                                            <li <?php echo $resultSubMenu > 0  ? 'class="menu-item-has-children"' : ''; ?>>
                                              <?php if ($mainMenuCheck['ready_link'] == "manualLink") { ?>
      <a <?php echo $mainMenuCheck['new_tab'] == 1 ? 'target="_blank"' : ''; ?> href="<?php echo $mainMenuCheck['link']; ?>" <?php echo $resultSubMenu > 0  ? 'data-toggle="  menu-item"' : ''; ?>><?php echo $mainMenuCheck['title']; ?></a>
    <?php }else{
      // if the ready link is a page link
      $pageLinkId = $mainMenuCheck['ready_link'];
      $pageLinkAsk=$db->prepare("SELECT * FROM posts WHERE post_id=$pageLinkId");
      $pageLinkAsk->execute();
      $pageLinkCheck=$pageLinkAsk->fetch(PDO::FETCH_ASSOC);
    ?>
      <a <?php echo $mainMenuCheck['new_tab'] == 1 ? 'target="_blank"' : ''; ?> href="<?php echo $pageLinkCheck['seo_url']; ?>" <?php echo $resultSubMenu > 0  ? '' : ''; ?>><?php echo $mainMenuCheck['title']; ?></a>
    <?php }
     $topMenuId = $mainMenuCheck['menu_id'];
     $subMenuAsk=$db->prepare("SELECT * FROM menu WHERE menu_top_id=$topMenuId  AND status=1 ORDER BY order_sort");
     $subMenuAsk->execute();
     // if the main menu has a submenu
     if ($resultSubMenu > 0) {
    ?>
                                                <ul class="sub-menu">
                                                   <?php
        while($subMenuCheck=$subMenuAsk->fetch(PDO::FETCH_ASSOC)){
          // if the submenu has a submenu
          $countSubmenu=$db->prepare("SELECT * FROM menu WHERE menu_top_id=:menu_top_id AND status=:status ORDER BY order_sort");
          $countSubmenu->execute(array(
            'menu_top_id' => $subMenuCheck['menu_id'],
            'status'      => 1
          ));
          $resultSubSubMenu=$countSubmenu->rowCount();
      ?> 
                                     <li>              <?php if ($subMenuCheck['ready_link'] == "manualLink") { ?>

            <a <?php echo $subMenuCheck['new_tab'] == 1 ? 'target="_blank"' : ''; ?> href="<?php echo $subMenuCheck['link']; ?>" <?php echo $resultSubSubMenu > 0  ? 'data-toggle="dropdown" class="dropdown-toggle"' : ''; ?>><?php echo $subMenuCheck['title']; ?></a>
          <?php }else{
            // if the ready link is a page link
            $subPageLinkId = $subMenuCheck['ready_link'];
            $subPageLinkAsk=$db->prepare("SELECT * FROM posts WHERE post_id=$subPageLinkId");
            $subPageLinkAsk->execute();
            $subPageLinkCheck=$subPageLinkAsk->fetch(PDO::FETCH_ASSOC);
          ?>
            <a <?php echo $mainMenuCheck['new_tab'] == 1 ? 'target="_blank"' : ''; ?> href="<?php echo $subPageLinkCheck['seo_url']; ?>" <?php echo $resultSubSubMenu > 0  ? 'data-toggle="dropdown" class="dropdown-toggle"' : ''; ?>><?php echo $subMenuCheck['title']; ?></a> <?php } ?>
          </li>
                                                <?php } ?> </ul>
                                           <?php } ?>  </li>
                                            <?php } ?>
                                       <?php
                  while ($langCheck=$langAsk->fetch(PDO::FETCH_ASSOC)){
                    $langCodeAsk=$db->prepare("SELECT * FROM countries where alpha=:alpha");
                    $langCodeAsk->execute(array(
                      'alpha' => $langCheck['country_code']
                    ));
                    $langCodeCheck=$langCodeAsk->fetch(PDO::FETCH_ASSOC);
                ?>
               
                  <a href="<?php echo $generalSettingCheck['site_url']; ?>?lang=<?php echo $langCheck['country_code']; ?>">
                    <i class='flag-icon flag-icon-<?php echo $langCheck['country_code'] ?> mr-2'></i>
                  </a>
              
                <?php } ?>  </ul>
                                       
                                