<div class="col-lg-9 col-md-12">
   <h6 class="py-4 fw-bold">Popular Categories</h6>
   <!--popular-list Begin-->
   <div class="popular-list">
      <ul class="list-inline">
         <?php 
            $sqlcategory="SELECT category_master.category,category_master.total_coupon,category_master.total_offers, coupon.category FROM  category_master  INNER JOIN  coupon ON category_master.category LIKE coupon.category ORDER BY rand() LIMIT 4";
                         $myquerycou=$conn->query($sqlcategory);
            $mydaracou= $myquerycou->fetchAll()  ;
            
            $rows_foundcou = $myquerycou->rowCount();
            
            foreach( $mydaracou as $rowcou ){
                  
                    $category = addslashes($rowcou["category"]); 
                    $category1=strtolower($category);
                     $rows_foundno = $rowcou["total_coupon"]; 
                 $rows_foundoff = $rowcou["total_offers"]; 
                   
                       $image  = $rowcn['image']; 
                       if($category!=''){
                         
            
                   
                    ?>
         <li>
            <a href="category-specific/<?=($category1)?>" class="cat-card">
               <div alt="<?=$category?>" title="<?=$category?>" class="popular-img-cat text-truncate"> 
                  <?=$category ?>
               </div>
               <div class="popular-coupon-offer-bottom">
                  <p class="border-right"><?=$rows_foundno?> Coupons</p>
                  <p><?=$rows_foundoff ?> Offers</p>
               </div>
            </a>
         </li>
         <?php  }    } ?>
      </ul>
   </div>
   <!--popular list end-->
   <div class="div">
      <h6 class="py-4 fw-bold">Browse All Categories</h6>
      <!-- browse-all -->
      <div class="browse-all">
         <!-- Nav pills -->
         <ul class="nav nav-pills" role="tablist">
            <!-- nav-link browse-all-->
            <li class="nav-item">
               <a class="nav-link active" data-bs-toggle="pill" href="#browse-all">ALL</a>
            </li>
            <!-- nav-link browse-merchant-hatch-->
            <li class="nav-item">
               <a class="nav-link" data-bs-toggle="pill" href="#browse-merchant-hatch">#</a>
            </li>
            <!-- nav-link browse-merchant-a-->
            <?php    foreach( range('a', 'z') as $elements) {  ?> 
            <li class="nav-item">
               <a class="nav-link" data-bs-toggle="pill" href="#browse-merchant-<?=$elements?>"><?=strtoupper($elements)?></a>
            </li>
            <?php } ?>
            <!-- nav-link browse-merchant-b-->
         </ul>
      </div>
      <!-- Tab panes -->
      <div class="tab-content">
         <!-- Tab pane all-->
         <div id="browse-all" class="tab-pane active">
            <div class="row">
               <?php 
                  $sqlcategory="SELECT * FROM  category_master";
                  $myquerycou=$conn->query($sqlcategory);
                  $mydaracou= $myquerycou->fetchAll()  ;
                  
                  $rows_foundcou = $myquerycou->rowCount();
                  
                  foreach( $mydaracou as $rowcou ){
                  
                  $category = addslashes($rowcou["category"]); 
                  $category1=strtolower($category);
                      $rows_foundno = $rowcou["total_coupon"]; 
                 $rows_foundoff = $rowcou["total_offers"]; 
                  $image  = $rowcn['image']; 
                  if($category!=''){
                  
                  if($rows_foundno!=0 || $rows_foundoff!=0){
                  ?>
               <div class="col-lg-4 col-6">
                  <!-- coupons-offers-->
                  <div class="coupons-offers">
                     <a href="category-specific/<?=($category1)?>">
                        <p alt="<?=$category?>" title="<?=$category?>" class="fw-bold text-default"><?=$category?></p>
                        <p> <span><?=$rows_foundno ?> Coupons</span><span><?=$rows_foundoff?> Offers</span> </p>
                     </a>
                  </div>
               </div>
               <?php } } } ?>
            </div>
         </div>
         <!-- Tab pane #-->
         <div id="browse-merchant-hatch" class="tab-pane fade">
            <div class="row">
               <?php 
                  $sqlcategory="SELECT * FROM  category_master WHERE category regexp '^[0-9]+'";
                  $myquerycou=$conn->query($sqlcategory);
                  $mydaracou= $myquerycou->fetchAll()  ;
                  
                  $rows_foundcou = $myquerycou->rowCount();
                  
                  foreach( $mydaracou as $rowcou ){
                  
                  $category = addslashes($rowcou["category"]); 
                  $category1=strtolower($category);
                     $rows_foundno = $rowcou["total_coupon"]; 
                 $rows_foundoff = $rowcou["total_offers"]; 
                           if($category!=''){
                  
                  
                  ?>

               <div class="col-lg-4 col-6">
                  <!-- coupons-offers category begin-->
                  <div class="coupons-offers">
                     <a href="category-specific/<?=($category1)?>">
                        <p alt="<?=$category?>" title="<?=$category?>" class="fw-bold text-default"><?=$category?></p>
                        <p> <span><?=$rows_foundno ?> Coupons</span><span><?=$rows_foundoff?> Offers</span> </p>
                     </a>
                  </div>
                  <!-- coupons-offers category end-->
               </div>
               <?php  } } ?>
            </div>
         </div>
         <!-- Tab pane a-->
         <?php    foreach( range('a', 'z') as $elements) {  ?>
         <div id="browse-merchant-<?=$elements?>" class="tab-pane fade">
            <div class="row">
               <?php 
                  $sqlcategory="SELECT * FROM  category_master WHERE category LIKE '$elements%'";
                  $myquerycou=$conn->query($sqlcategory);
                  $mydaracou= $myquerycou->fetchAll()  ;
                  
                  $rows_foundcou = $myquerycou->rowCount();
                  
                  foreach( $mydaracou as $rowcou ){
                  
                  $category = addslashes($rowcou["category"]);
                  $category1=strtolower($category);
                  $rows_foundno = 0;
                  $rows_foundoff = 0;
                     $rows_foundno = $rowcou["total_coupon"]; 
                 $rows_foundoff = $rowcou["total_offers"]; 
                  if($category!=''){
                  
                  
                  ?>
               <div class="col-lg-4 col-6">
                  <!-- coupons-offers begin-->
                  <div class="coupons-offers">
                     <a href="category-specific/<?=($category1)?>">
                        <p alt="<?=$category?>" title="<?=$category?>" class="fw-bold text-default"><?=$category?></p>
                        <p> <span><?=$rows_foundno ?> Coupons</span><span><?=$rows_foundoff?> Offers</span> </p>
                     </a>
                  </div>
                  <!-- coupons-offers end-->
               </div>
               <?php } } ?>
            </div>
         </div>
         <?php } ?>
         <!-- Tab pane b-->
      </div>
   </div>
</div>