<?php
error_reporting(0);
include('header.php');

// $str_jsonAry_decoded = $json['searchkeyword'];
// $search_total = $json['searchkeyword2'];
//echo "<pre>";
//print_r($json['searchkeyword']);
$str_jsonAry_decoded_rand = $json['total_postlist3'];


$afflink = '';
//$searchword= $json['searchword'];
?>

<?php 
                     
   $cat_type = str_replace(' ', '_', $_GET['searchkey']);


   if($cat_type =="")
   {
      $cat_type ="Digital_Marketing";
   }
   else
   {
      $cat_type = $cat_type;
   }

   if($_GET['page'] != ""){
      $page = $_GET['page'];
   }
   else{
      $page = 1;
   }


   $handle3 = curl_init();
   $url = "https://app.autohealthsites.com/udemylist.php";
   curl_setopt($handle3, CURLOPT_URL, $url);
   curl_setopt($handle3, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($handle3, CURLOPT_CUSTOMREQUEST, 'POST');
   curl_setopt($handle3, CURLOPT_SSL_VERIFYPEER, false );
   curl_setopt($handle3, CURLOPT_POSTFIELDS, 'searchkey='.$cat_type.'&page='.$page.'');
   $output3 = curl_exec($handle3);
   curl_close($handle3);

   $json = json_decode($output3, true);


   ?>

<!-- ======================== Breadcrumb one Section Start ===================== -->
      <section class="breadcrumb breadcrumb-one padding-y-60 section-bg position-relative z-index-1 overflow-hidden">
         <img src="assets/images/gradients/breadcrumb-gradient-bg.png" alt="" class="bg--gradient">
         <img src="assets/images/shapes/element-moon3.png" alt="" class="element one">
         <img src="assets/images/shapes/element-moon1.png" alt="" class="element three">
         <div class="container container-two">
            <div class="row justify-content-center">
               <div class="col-lg-7">
                  <div class="breadcrumb-one-content">
                     <h3 class="breadcrumb-one-content__title text-center mb-3 text-capitalize">1,040+ products available for purchase</h3>
                     <p class="breadcrumb-one-content__desc text-center text-black-three">Explore the best premium courses available for sale. Our unique collection is hand-curated by experts. Find and buy the perfect premium theme.</p>
                     <form action="courses-list.php" method="GET" class="search-box">
                        <input type="text" class="common-input common-input--lg pill shadow-sm" placeholder="Search Courses, Technology Courses &amp; more..." name="searchkey" value="<?php echo $_GET['searchkey'];?>">
                        <button type="submit" class="btn btn-main btn-icon icon border-0">
                        <img src="assets/images/icons/search.svg" alt="">
                        </button>
                     </form>
                  </div>
               </div>
            </div>
         </div>
      </section>
      <!-- ======================== Breadcrumb one Section End ===================== -->
      
      
      <!-- ======================== All Product Section Start ====================== -->
      <section class="all-product padding-y-120">
         <div class="container container-two">
            <div class="row">
               <div class="col-lg-12">
                  
                  
               </div>
               <div class="col-xl-3 col-lg-4">
                  <!-- ===================== Filter Sidebar Start ============================= -->
                  <div class="filter-sidebar">
                     <button type="button" class="filter-sidebar__close p-2 position-absolute end-0 top-0 z-index-1 text-body hover-text-main font-20 d-lg-none d-block"><i class="las la-times"></i></button>
                     <div class="filter-sidebar__item">
                        <button type="button" class="filter-sidebar__button font-16 text-capitalize fw-500">Category</button>
                        <div class="filter-sidebar__content">
                           <ul class="filter-sidebar-list">
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=1" class="filter-sidebar-list__text">
                                 Wordpress 
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=2" class="filter-sidebar-list__text">
                                 Plugin
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=3" class="filter-sidebar-list__text">
                                PHP Script
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=4" class="filter-sidebar-list__text">
                                 HTML Template
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=5" class="filter-sidebar-list__text">
                                 Laravel
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=6" class="filter-sidebar-list__text">
                                 Sketch 
                                 </a>
                              </li>
                              <!--<li class="filter-sidebar-list__item">-->
                              <!--   <a href="productcat.php?id=7" class="filter-sidebar-list__text">-->
                              <!--   Figma-->
                              <!--   </a>-->
                              <!--</li>-->
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=8" class="filter-sidebar-list__text">
                                 Bootstrap
                                 </a>
                              </li>
                              <!--<li class="filter-sidebar-list__item">-->
                              <!--   <a href="productcat.php?id=9" class="filter-sidebar-list__text">-->
                              <!--   Tailwind-->
                              <!--   </a>-->
                              <!--</li>-->
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=10" class="filter-sidebar-list__text">
                                 React
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=11" class="filter-sidebar-list__text">
                                 Java Script
                                 </a>
                              </li>
                              <li class="filter-sidebar-list__item">
                                 <a href="productcat.php?id=12" class="filter-sidebar-list__text">
                                 Mobile App
                                 </a>
                              </li>
                           </ul>
                        </div>
                     </div>
                     <div class="filter-sidebar__content">
                     <?php
                     if($homebanner != '')
                     {
                         echo $homebanner;
                     }
                     else
                     {
                     ?>
                     
                     <a href="https://www.amazon.com/" target="_blank">
                         <img src="sidebar.png" class="" alt="" style="width: 100%;">
                     </a>
                    <?php
                     }
                     ?>
                     </div>
                  </div>
                  <!-- ===================== Filter Sidebar End ============================= -->
               </div>
               <div class="col-xl-9 col-lg-8">
                  <div class="tab-content" id="pills-tabContent">
                     <div class="tab-pane fade show active" id="pills-product" role="tabpanel" aria-labelledby="pills-product-tab" tabindex="0">
                        <div class="row gy-4 list-grid-wrapper">
                            <?php
                              foreach($json['results'] as $results) {
            
                           ?>
                           <div class="col-xl-4 col-sm-6">
                              <div class="product-card section-bg">
                                 <div class="product-card__thumb d-flex">
                                    <a href="course-detail.php?trackId=<?php echo $results['id'];?>&cat_type=<?php echo $cat_type;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>" class="link w-100">
                                    <img src="<?php echo $results['image_480x270']; ?>" alt="" class="cover-img"> 
                                    </a>
                                   
                                 </div>
                                 <div class="product-card__content">
                                    <h6 class="product-card__title">
                                       <a href="course-detail.php?trackId=<?php echo $results['id'];?>&cat_type=<?php echo $cat_type;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>" class="link"><?php echo $productlist[$i]['pagename'];?></a>
                                    </h6>
                                    <div class="product-card__info flx-between gap-2">
                                       <span class="product-card__author">
                                       
                                       <a href="#" class="link hover-text-decoration-underline"> <?php echo $results['title'];?></a>
                                       </span>
                                       <div class="flx-align gap-2">
                                         
                                          <!--<span class="product-card__prevPrice text-decoration-line-through">$259</span>-->
                                       </div>
                                    </div>
                                    <div class="product-card__bottom flx-between gap-2">
                                       <div>
                                          
                                          
                                       </div>
                                       <a href="course-detail.php?trackId=<?php echo $results['id'];?>&cat_type=<?php echo $cat_type;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>" class="btn btn-outline-light btn-sm pill">Read More</a>
                                    </div>
                                 </div>
                              </div>
                           </div>
                            <?php
                            }
                            
                            
                        if($_GET['page']){
                              $m=$_GET['page'];
                              $page=$_GET['page']; 
                          }
                          else{
                                      $m=1;
                                      $page=1;
                          }
                            ?>
                        </div>
                        
                        <!-- Pagination Start -->
                        <nav aria-label="Page navigation example">
                           <ul class="pagination common-pagination">
                              <li class="page-item">
                                 <a class="page-link flx-align gap-2 flex-nowrap" href="courses-list.php?page=<?php echo $m-1;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>"> 
                                 <span class="icon line-height-1 font-20"><i class="las la-arrow-left"></i></span> 
                                 </a>
                              </li>
                             
                              <li class="page-item"><a class="page-link" href="courses-list.php?page=<?php echo $m;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>"><?php echo $m;?></a></li>
                            
                              <li class="page-item">
                                 <a class="page-link flx-align gap-2 flex-nowrap" href="courses-list.php?page=<?php echo $m+1;?>&searchkey=<?php echo str_replace(' ','+',$_GET['searchkey']);?>"> 
                                 <span class="icon line-height-1 font-20"><i class="las la-arrow-right"></i></span> 
                                 </a>
                              </li>
                           </ul>
                        </nav>
                        <!-- Pagination End -->
                     </div>
                    
                    
                  </div>
               </div>
            </div>
         </div>
      </section>
      <!-- ======================== All Product Section End ====================== -->


<?php
include_once('footer.php');


?>