<?php 
include_once("include/main.inc.php"); 
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

 if(isset($_POST['loadmores'])){
    $error = array('success' => false);
    $in = $_POST;
    if(empty($in['start']) || !ctype_digit($in['start'])){$error['msg'] = 'invalid start';}
    if(empty($in['whr'])){$error['msg'] = 'invalid start';}
    if(!isset($error['msg'])){
    $target_location = $_POST['loadmores'];
   $whr= $_POST['whr'];
   $start=$_POST['start'];
   $product_s = mysqli_query($GLOBALS['dbconn'], "select product_image,product_title,catalog,product_id,product_video,product_status,product_specfi from product_tbl WHERE product_status='1' AND " .$whr." order by product_id desc limit ".$start.",  6 ");
                       
                          ?>
                       

                        <!-- <div class="you_may">You may Also Like These</div> -->

                     

                             <?php $i = 1;
                            while ($product_r = mysqli_fetch_array($product_s)) {
                                $pro_image =  explode(',', $product_r['product_image']);
                                $probig_img = $pro_image[0];
                                $imgname = explode('.', $pro_image[0]);
                                $prod_img = getImage($probig_img, 500, 500, $product_r['product_title'] . $imgname[0], "/uploaded-files/product-images/");
                                $prod_imgsmall = getImage($probig_img, 47, 47, $product_r['product_title'], "/uploaded-files/product-images/");
                            ?>

                                   <div class="pr-li mb-3 productlist">
                                    <div class="row g-0">
                                        <div class="col-lg-4 col-md-5 col-12 g_col">
                                            <div class="img_bx">
                                                <a class="main-img" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#productID" onclick="var src = $(this).find('img.clickable-image').attr('src');$('.catID').val('<?php echo $product_r['product_id']; ?>');$('.catName').html('<?php echo $product_r['product_title']; ?>');  $('.catImg').attr('src', src); $('.catImg').attr('alt','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>'); $('.catImg').attr('title','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>');" title="<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>">
                                                    <img id="mainImage<?= $product_r['product_id']; ?>" src="<?= $prod_img; ?>" class="clickable-image" alt="<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>"
                                                        title="<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>">
                                                </a>
                                                <div class="multi-imgs">
                                                    <?php
                                                    if (!empty($pro_image[1])) {
                                                        $snn = 1;
                                                        foreach ($pro_image as $pro_imag_vals) { ?>
                                                            <div class="imgs <?= $snn == 1 ? 'active' : ''; ?>" onclick="imgMulti(<?= $product_r['product_id']; ?>, '<?= getImage($pro_imag_vals, 375, 375, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>', this)">
                                                                <img src="<?= getImage($pro_imag_vals, 60, 60, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>" alt="<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>" title="<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>">
                                                            </div>
                                                    <?php $snn++;
                                                        }
                                                    } ?>
                                                    <!-- <div class="imgs" onclick="imgMulti(1, 'designer/images/category/Hex-84-Operation-Theater-Light.jpg', this)">
                                                <img src="designer/images/category/Hex-84-Operation-Theater-Light.jpg" alt="">
                                            </div>
                                            <div class="imgs" onclick="imgMulti(1, 'designer/images/category/Nova-D4-LED-OT-Light.jpg', this)">
                                                <img src="designer/images/category/Nova-D4-LED-OT-Light.jpg" alt="">
                                            </div> -->
                                                    <?php if ($product_r['product_video'] != '') { ?>
                                                        <div class="imgs youTube">
                                                            <a data-fancybox="" href="https://www.youtube.com/watch?v=<?= $product_r['product_video']; ?>">
                                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
                                                                    <path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"></path>
                                                                </svg>
                                                            </a>
                                                        </div>
                                                    <?php } ?>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-8 col-md-7 col-12 g_col">
                                            <div class="tx-bx">
                                                <h4 class="title"><?= $product_r['product_title']; ?> in <?=$target_location; ?></h4>
                                                <div class="btn-grp">
                                                    <?php if ($product_r['catalog'] != '') { ?>
                                                        <div class="productBrochureandvideo">
                                                            <a href="<?= site_url; ?>/uploaded-files/pdf/<?= $product_r['catalog']; ?>" title="Product Brochure" target="_blank">
                                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filetype-pdf" viewBox="0 0 16 16">
                                                                    <path fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38.574.574 0 0 1-.238.241.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181.123.122.185.296.185.522Zm1.217-1.333v3.999h1.46c.401 0 .734-.08.998-.237a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084 0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.589-.68c-.264-.156-.599-.234-1.005-.234H3.362Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592 1.14 1.14 0 0 1-.196.422.8.8 0 0 1-.334.252 1.298 1.298 0 0 1-.483.082h-.563v-2.707Zm3.743 1.763v1.591h-.79V11.85h2.548v.653H7.896v1.117h1.606v.638H7.896Z">
                                                                    </path>
                                                                </svg>
                                                                <span>Product Brochure</span>
                                                            </a>
                                                        </div>
                                                    <?php } ?>
                                                </div>
                                                <div class="info">
                                                    <?= html_entity_decode($product_r['product_specfi']); ?>
                                                </div>
                                                <div class="bt_bx">
                                                    <button class="readBtn_1" data-bs-toggle="modal" data-bs-target="#callback" onclick="$('.catID').val('<?php echo $product_r['product_id']; ?>');$('.catName').html('<?php echo $product_r['product_title']; ?>');  $('.catImg').attr('src','<?= getImage($probig_img, 300, 300, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>'); $('.catImg').attr('alt','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>'); $('.catImg').attr('title','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>');" title="Request A Callback">
                                                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-telephone-fill" viewBox="0 0 16 16">
                                                            <path fill-rule="evenodd" d="M1.885.511a1.745 1.745 0 0 1 2.61.163L6.29 2.98c.329.423.445.974.315 1.494l-.547 2.19a.68.68 0 0 0 .178.643l2.457 2.457a.68.68 0 0 0 .644.178l2.189-.547a1.75 1.75 0 0 1 1.494.315l2.306 1.794c.829.645.905 1.87.163 2.611l-1.034 1.034c-.74.74-1.846 1.065-2.877.702a18.6 18.6 0 0 1-7.01-4.42 18.6 18.6 0 0 1-4.42-7.009c-.362-1.03-.037-2.137.703-2.877z"></path>
                                                        </svg> Request A Callback</button>
                                                        <button class="readBtn_2" data-bs-toggle="modal" data-bs-target="#productID" onclick="$('.catID').val('<?php echo $product_r['product_id']; ?>');$('.catName').html('<?php echo $product_r['product_title']; ?>');  $('.catImg').attr('src','<?= getImage($probig_img, 500, 500, $product_r['product_title'] . $product_r['product_id'] . $snn, '/uploaded-files/product-images/'); ?>'); $('.catImg').attr('alt','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>'); $('.catImg').attr('title','<?= $product_r['product_title']; ?> Manufacturers, Suppliers, Exporters in <?= $target_location; ?>');" title="Get Best Quote"><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> Get Best Quote</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <?php $i++;
            } } }?>
            