<div class="container-fluid">
    <div class="row">
      <div class="col-lg-12">
        <div class="page-content">

          <!-- ***** Banner Start ***** -->
          <div class="row">
            <div class="col-lg-12">
              <div class="main-profile ">
                <div class="row">
                  <div class="col-lg-4">
                    <img src="uploads/profile.jpg" alt="" style="border-radius: 23px;">
                  </div>
                  <div class="col-lg-8 align-self-center">
                    <div class="main-info header-text">
                      <span>Categories</span>
                      <h4>Welcome to the Categories Game!</h4>
                      <p>Choose from a variety of fun and challenging categories to test your knowledge and quick thinking. Whether you're playing solo or with friends, pick a category to get started and see how many items you can name!</p>
                    </div>
                  </div>
                  
                </div>
                
                <div class="row mt-4">
                <div class="col-lg-12 align-self-center">
                    <ul>
                        
                        <?php $sql  = $pdo->query("SELECT * FROM tb_game_categories")or die(print_r($pdo->errorInfo(), true)); ?>
                        <?php while($data = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
                        
                        <?php 
                        $game  = $pdo->query("SELECT * FROM tb_games WHERE game_category_id = '".$data['id']."'")or die(print_r($pdo->errorInfo(), true)); 
                        $game_count = $game->rowCount();
                        ?>
                        
                        <li><a href="<?php echo BASE_URL; ?>/category/<?php echo $data['game_category_url']; ?>"><?php echo $data['game_category_name']; ?></a><span><?php echo $game_count; ?></span></li>
                      
                        <?php } ?>
                    </ul>
                  </div>
                </div>
                
                <div class="row">
                  <div class="col-lg-12">
                    <div class="clips">
                      <div class="row">
                        <div class="col-lg-12">
                          <div class="heading-section">
                            <h4><em>Your Most Popular</em> Games</h4>
                          </div>
                        </div>
                        
                        <?php $sql  = $pdo->query("SELECT * FROM tb_games ORDER BY view DESC LIMIT 8")or die(print_r($pdo->errorInfo(), true)); ?>
                        <?php while($data = $sql->fetch(PDO::FETCH_ASSOC)){ ?>
                        <?php 
                        $cat  = $pdo->query("SELECT * FROM tb_game_categories WHERE id = '".$data['game_category_id']."'")or die(print_r($pdo->errorInfo(), true)); 
                        $data_cat = $cat->fetch(PDO::FETCH_ASSOC)
                        ?>
                        
                        <div class="col-lg-3 col-sm-6">
                          <div class="item">
                            <div class="thumb">
                                <?php $image_path = (empty($data['image'])) ? "" . BASE_URL . "/img/default-bg.png" : "" . BASE_URL . "/uploads/".$data['image']; ?>
                              <img src="<?php echo $image_path; ?>" alt="" style="border-radius: 23px;">
                              <a href="<?php echo BASE_URL; ?>/games/<?php echo $data['game_slug']; ?>"><i class="fa fa-play"></i></a>
                            </div>
                            <div class="down-content">
                              <h4><?php echo $data['game_title']; ?></h4>
                              <span><i class="fa fa-eye"></i> <?php echo number_format($data['view']); ?></span>
                            </div>
                          </div>
                        </div>
                        
                        <?php } ?>
                        
                        <div class="col-lg-12">
                          <div class="main-button">
                            <a href="<?php echo BASE_URL; ?>/populer">Discover Populer</a>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!-- ***** Banner End ***** -->
        </div>
      </div>
    </div>
  </div>