<?php   $sqlc = "SELECT * FROM company_master ORDER BY rand() LIMIT 1 ";
   $myq=$conn->query($sqlc);
   $mydar= $myq->fetchAll()  ;
   
   $rows_fou = $myq->rowCount(); ?>
<section class="bg-white py-4">
   <div class="container">
      <div class="row">
         <div class="col-md-6">
            <div class="bottom-line">
               <h2 class="h5 mb-4">Popular Stores</h2>
            </div>
         </div>
         <div class="col-md-6">
            <div class="view-all-details">
               <a href="stores" class="btn btn-outline-dark">
                  <span>
                     View All 
                     <i>
                        <svg style="transform:rotate(90deg)" width="8px" height="13px" viewBox="0 0 8 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                           <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                              <g transform="translate(-1228.000000, -4044.000000)" fill="#fff" fill-rule="nonzero">
                                 <path d="M1235.71217,4051.14357 L1229.6777,4056.73319 C1229.29383,4057.08894 1228.67146,4057.08894 1228.28778,4056.73319 C1227.90407,4056.37775 1227.90407,4055.80127 1228.28778,4055.44587 L1233.62736,4050.49991 L1228.28794,4045.55412 C1227.90423,4045.19854 1227.90423,4044.62212 1228.28794,4044.26668 C1228.67165,4043.91111 1229.29399,4043.91111 1229.67785,4044.26668 L1235.71233,4049.85639 C1235.90418,4050.03419 1236,4050.26698 1236,4050.49988 C1236,4050.73289 1235.90399,4050.96585 1235.71217,4051.14357 Z"></path>
                              </g>
                           </g>
                        </svg>
                     </i>
                  </span>
               </a>
            </div>
         </div>
      </div>
      <div class="row align-items-center">
         <div class="col-md-3">
            <?php foreach( $mydar as $rowcn) { 
               $company  =addslashes($rowcn['company']);
               $company1 = str_replace(" ","-","$company");
               $company1 = strtolower($company1);
               $image  = $rowcn['image']; 
               $sql_coupon_count="SELECT company_name FROM coupon WHERE company_name='$company'";
               
               $myquery_coupon_count=$conn->query($sql_coupon_count);
               $mydaracou_coupon_count= $myquery_coupon_count->fetchAll()  ;
               
               $rows_found_coupon_count = $myquery_coupon_count->rowCount();
               ?>
            <div class="popular-store-left store-of-the-month">
               <h6 class="text-center">Featured Store Of The Month</h6>
               <?php     if (!filter_var($image, FILTER_VALIDATE_URL) === false) { ?>
               <img src="<?=$image?>" alt="<?=$company ?>" title="<?=$company ?>" class="img-fluid my-3 mx-auto d-block">
               <?php  } else { ?>
               <a class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                  <!-- <img src="images/merchant/myntra-logo.jpg" alt="Avatar" class="w-100 img-fluid store-overlay"> -->
                  <span class="f-store text-truncate"><?=$company ?></span>
               </a>
               <?php } ?>
               <a href="./store-coup/<?=($company)?>" class="btn btn-outline-store mx-auto d-block"> <?=$rows_found_coupon_count?> Coupons & Offers Available</a>
            </div>
            <?php } ?>
         </div>
         <div class="col-md-9">
            <!-- Carousel -->
            <div id="store" class="carousel slide" data-bs-ride="carousel">
               <!-- Indicators/dots -->
               <div class="carousel-indicators">
                  <button type="button" data-bs-target="#store" data-bs-slide-to="0" class="active"></button>
                  <button type="button" data-bs-target="#store" data-bs-slide-to="1"></button>
                 
               </div>
               <!-- The slideshow/carousel -->
               <div class="carousel-inner">
                  <!-- carousel-item  active popular store-->
                  <div class="carousel-item active">
                     <div class="row">
                        <?php   $sqlc = "SELECT * FROM company_master ORDER BY rand() LIMIT 36";
                           $myq=$conn->query($sqlc);
                           $mydar= $myq->fetchAll()  ;
                           
                           $rows_fou = $myq->rowCount();
                           
                           
                           
                           //print_r($mydar[$mydar_key[0]]);
                           
                           $initial = 0;
                           
                           
                           
                           foreach( $mydar as $rowcn) {
                           
                             if($initial>=0 && $initial<12){
                             
                               $country  = $rowcn['country'];
                                $company  = addslashes($rowcn['company']);
                                $company1 = str_replace(" ","-","$company");
                                $company1 = strtolower($company1);
                                 $image  = $rowcn['image']; 
                            
                                 $sql_coupon_count="SELECT company_name FROM coupon WHERE company_name='$company'";
                           
                           $myquery_coupon_count=$conn->query($sql_coupon_count);
                           $mydaracou_coupon_count= $myquery_coupon_count->fetchAll()  ;
                           
                           $rows_found_coupon_count = $myquery_coupon_count->rowCount();
                           
                                 ?>
                        <div class="col-4 col-lg-3">
                           <div class="carousal-store-right">
                              <?php     if (!filter_var($image, FILTER_VALIDATE_URL) === false) { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <img src="<?=$image ?>" alt="Avatar" class="w-100 img-fluid store-overlay">
                              </a>
                              <?php }else { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <span class="c-store text-truncate"><?=$company ?> </span>
                              </a>
                              <?php } ?>
                              <a class="text-white text-decoration-underline" href="./store-coup/<?=($company1)?>">
                                 <div class="overlay text-truncate" title="<?=$company ?> Coupons">
                                    <div class="text">
                                       <p class="text-white text-truncate"><?=$company ?></p>
                                       <p>
                                          <?=$rows_found_coupon_count?> Coupons
                                       </p>
                                    </div>
                                 </div>
                              </a>
                           </div>
                        </div>
                        <?php   }  $initial=$initial+1;
                           } ?>
                     </div>
                  </div>
                  <!-- carousel-item popular store-->
                  <div class="carousel-item">
                     <div class="row">
                        <?php    
                           $initial = 0;
                                              
                                                     foreach($mydar as $rowcn) {
                           
                                                        if( $initial>=12 && $initial<24){
                                 
                                   $country  = $rowcn['country'];
                                    $company  = addslashes($rowcn['company']);
                                    $company1 = str_replace(" ","-","$company");
                                       $company1 = strtolower($company1);
                                     $image  = $rowcn['image']; 
                           
                                      $sql_coupon_count="SELECT company_name FROM coupon WHERE company_name='$company'";
                           
                              $myquery_coupon_count=$conn->query($sql_coupon_count);
                              $mydaracou_coupon_count= $myquery_coupon_count->fetchAll()  ;
                              
                              $rows_found_coupon_count = $myquery_coupon_count->rowCount();
                           
                                     ?>
                        <div class="col-4 col-lg-3">
                           <div class="carousal-store-right">
                              <?php     if (!filter_var($image, FILTER_VALIDATE_URL) === false) { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <img src="<?=$image ?>" alt="Avatar" class="w-100 img-fluid store-overlay">
                              </a>
                              <?php }else { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <span class="c-store text-truncate"><?=$company ?></span>
                              </a>
                              <?php } ?>
                              <a class="text-white text-decoration-underline"href="./store-coup/<?=($company1)?>">
                                 <div class="overlay" title="<?=$company ?> Coupons">
                                    <div class="text">
                                       <p class="text-white text-truncate"><?=$company ?></p>
                                       <p>
                                          <?=$rows_found_coupon_count?> Coupons
                                       </p>
                                    </div>
                                 </div>
                              </a>
                           </div>
                        </div>
                        <?php }  $initial=$initial+1; } ?>
                     </div>
                  </div>
                  <!-- carousel-item popular store-->
                  <div class="carousel-item">
                     <div class="row">
                        <?php  $initial = 0;
                           foreach($mydar as $rowcn) {
                           
                            if( $initial>=24 && $initial<36){
                           
                           $country  = $rowcn['country'];
                           $company  = $rowcn['company'];
                           $company1 = str_replace(" ","-","$company");
                              $company1 = strtolower($company1);
                           $image  = $rowcn['image'];
                           $sql_coupon_count="SELECT company_name FROM coupon WHERE company_name='$company'";
                           
                           $myquery_coupon_count=$conn->query($sql_coupon_count);
                           $mydaracou_coupon_count= $myquery_coupon_count->fetchAll()  ;
                           
                           $rows_found_coupon_count = $myquery_coupon_count->rowCount(); 
                           
                           ?>
                        <div class="col-4 col-lg-3">
                           <div class="carousal-store-right">
                              <?php     if (!filter_var($image, FILTER_VALIDATE_URL) === false) { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <img src="<?=$image ?>" alt="Avatar" class="w-100 img-fluid store-overlay">
                              </a>
                              <?php }else { ?>
                              <a  class="text-decoration-none" href="./store-coup/<?=($company1)?>">
                              <span class="c-store text-truncate"><?=$company ?></span>
                              </a>
                              <?php } ?>
                              <a class="text-white text-decoration-underline" href="./store-coup/<?=($company1)?>">
                                 <div class="overlay" title="<?=$company ?> Coupons">
                                    <div class="text">
                                       <p class="text-white text-truncate"><?=$company ?></p>
                                       <p>
                                          <?=$rows_found_coupon_count?> Coupons
                                       </p>
                                    </div>
                                 </div>
                              </a>
                           </div>
                        </div>
                        <?php   }  $initial=$initial+1;} ?>
                     </div>
                  </div>
               </div>
               <!-- Left and right controls/icons -->
               <button class="carousel-control-prev" type="button" data-bs-target="#store" data-bs-slide="prev">
               <span class="carousel-box-left"><span class="carousel-control-prev-icon"></span></span>
               </button>
               <button class="carousel-control-next" type="button" data-bs-target="#store" data-bs-slide="next">
               <span class="carousel-box-right"><span class="carousel-control-next-icon"></span></span>
               </button>
            </div>
         </div>
      </div>
   </div>
</section>