<header>
  <div class="logo">
     <i class="fas fa-gamepad" style="color: #f0a500;"></i> <i><span style="color: red;">O</span>NE<span style="color: #f0a500;">G</span>AMES</i>
  </div>
  
  <!-- ***** Search End ***** -->
                    <div class="search-input">
                      <form id="search" action="<?php echo BASE_URL; ?>/search/">
                        <input type="text" placeholder="Type Something" id='searchText' name="searchKeyword" onkeypress="handle" />
                        <i class="fa fa-search"></i>
                      </form>
                    </div>
                    <!-- ***** Search End ***** -->

  <!-- Desktop menu -->
  <nav class="desktop-menu" aria-label="Primary navigation">
    <ul class="menu">
      <li><a href="<?php echo BASE_URL; ?>" class="<?php if($segment[2] == '') { print('active'); } ?>">Home</a></li>
      <li class="has-dropdown">
        <a href="#" aria-haspopup="true" aria-expanded="false">Categories</a>
        <ul class="dropdown" role="menu">
          <?php $sql  = $pdo->query("SELECT distinct game_category FROM zon_games")or die(print_r($pdo->errorInfo(), true)); ?>
                        <?php while($data = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
                        
                        <?php 
                        $game  = $pdo->query("SELECT * FROM zon_games WHERE game_category = '".$data['game_category']."'")or die(print_r($pdo->errorInfo(), true)); 
                        $game_count = $game->rowCount();
                        ?>
                        
                        <li><a href="<?php echo BASE_URL; ?>/category/<?php echo url_strip($data['game_category']); ?>"><?php echo $data['game_category']; ?></a> <span class="badge text-warning"><?php echo $game_count; ?></span></li>
                      
                        <?php } ?>
        </ul>
      </li>
      <li><a href="<?php echo BASE_URL; ?>/autoplay" class="<?php if($segment[2] == 'autoplay') { print('active'); } ?>">Autoplay</a></li>
      <li>
          <?php if (!isset($_SESSION['username'])) { ?>
          <a href="<?php echo BASE_URL; ?>/dashboard/login.php">Login</a>
          <?php }else{ ?>
          <a href="<?php echo BASE_URL; ?>/logout.php">Logout</a>
          <?php } ?>
      </li>
    </ul>
  </nav>

  <!-- Hamburger button mobile -->
  <button class="hamburger" aria-label="Open menu" aria-expanded="false" aria-controls="mobile-menu">
    <span></span>
    <span></span>
    <span></span>
  </button>
</header>

<!-- Mobile menu sidebar -->
<nav id="mobile-menu" aria-label="Mobile navigation">
  <ul class="menu">
    <li><a href="#">Home</a></li>
    <li class="has-dropdown">
      <button class="dropdown-toggle" aria-expanded="false">
        Categories <!--<span class="arrow">▼</span>-->
      </button>
      <ul class="dropdown">
        <?php $sql  = $pdo->query("SELECT * FROM zon_games")or die(print_r($pdo->errorInfo(), true)); ?>
                        <?php while($data = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
                        
                        <?php 
                        $game  = $pdo->query("SELECT * FROM zon_games WHERE game_category = '".$data['game_category']."'")or die(print_r($pdo->errorInfo(), true)); 
                        $game_count = $game->rowCount();
                        ?>
                        
                        <li><a href="<?php echo BASE_URL; ?>/category/<?php echo url_strip($data['game_category']); ?>"><?php echo $data['game_category']; ?> <span class="badge text-warning"><?php echo $game_count; ?></span></a></li>
                      
                        <?php } ?>
      </ul>
    </li>
    <li><a href="#">Autoplay</a></li>
    <li><a href="#">Login</a></li>
  </ul>
</nav>