<?php
include('include/main.inc.php');
$web_det_query = "Select * from admin_details where slno = '1'";
$res_web = $dbconn->query($web_det_query);
$web_details = $res_web->fetch_assoc();
$page_metatitle = $web_details['companyName'].' - Search';
$page_metadesc = $web_details['companyName'].' - Search';
$page_metakey = $web_details['companyName'].' - Search';

$no_search = 0;
if(isset($_GET['keyword'])){
    $search = $_GET['keyword'];
    $search_query = "select * from category_tbl where catName like '%".$search."%'";
    $res_query = $dbconn->query($search_query);
    $no_search = $res_query->num_rows;
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?= $page_metatitle; ?></title>
    <meta name="description" content="<?= $page_metadesc; ?>">
    <meta name="keywords" content="<?= $page_metakey; ?>">
    <?php include "app_top.php"; ?>
</head>

<body>

    <?php include "app_header.php"; ?>

    <section class="heading_banner" style="background-image: url(<?= site_url; ?>/designer/images/category-banner.jpg)">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-center">
                    <h1 class="cat_title">Search result for <strong>"<?= $search.' ('.$no_search.')'; ?>"</h1>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </section>

    <div class="inner_breadcrumb hidden_xs">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <ul class="breadcrumb">
                        <li><a href="<?= site_url; ?>" title="Home">Home</a></li>
                        <li class="active">Search Results</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <section class="category_page">
        <div class="container">
            <h2 class="title_2">Search Results for "<?= $search; ?>" (<?= $no_search; ?>) Items</h2>
            <div class="clearfix"></div>
            <div class="row">
                <?php 
                if($res_query->num_rows > 0){
                  while($results = $res_query->fetch_assoc()){
                      $sub_cat_title = str_ireplace(" ", "-", $results['catName']);
                ?>
                <div class="col-xxl-3 col-xl-3 col-lg-3 col-md-3 col-sm-6 col-12">
                    <div class="rangeProduct">
                        <a href="<?= site_url.'/'.strtolower($sub_cat_title).'.htm'; ?>" title="<?= $results['displayName']; ?>">
                            <div class="image">
                                <img src="<?= site_url.'/'.'uploaded-files/category/images/'.$results['catImage']; ?>" alt="<?= $results['displayName']; ?>" title="<?= $results['displayName']; ?>">
                            </div>
                            <h3 class="rangeTitle"><?= $results['displayName']; ?></h3>
                            <span class="read_more_btn"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                    <path d="M.05 3.555A2 2 0 0 1 2 2h12a2 2 0 0 1 1.95 1.555L8 8.414.05 3.555ZM0 4.697v7.104l5.803-3.558L0 4.697ZM6.761 8.83l-6.57 4.027A2 2 0 0 0 2 14h12a2 2 0 0 0 1.808-1.144l-6.57-4.027L8 9.586l-1.239-.757Zm3.436-.586L16 11.801V4.697l-5.803 3.546Z"></path>
                                </svg> Read More</span>
                        </a>
                    </div>
                </div>
                <?php } }else{ ?>
                <span>No result found!!!</span>
              <?php } ?>

            </div>
        </div>
    </section>


    <?php include "app_footer.php"; ?>
    <?php include "app_bottom.php"; ?>
   
</body>

</html>
<?php }else{
    header('location:'.site_url);
} ?>