コード例 #1
0
ファイル: index.php プロジェクト: rpuri56/git-test-branch
<?php

$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die("Could not connect");
$aData = array('name' => 'table', 'color' => 'brown', 'size' => array('x' => 200, 'y' => 120, 'z' => 150), 'strength' => 10);
require_once 'memcache.caching.php';
$oCache = new CacheMemcache();
echo 'Initial data: <pre>';
// lets see what we have
print_r($aData);
echo '</pre>';
if ($oCache->bEnabled) {
    // if Memcache enabled
    $oCache->setData('my_object', $aData);
    // saving data to cache server
    $oCache->setData('our_class_object', $oCache);
    // saving object of our class into cache server too
    echo 'Now we saved all in cache server, click <a href="index2.php">here</a> to check what we have in cache server';
} else {
    echo 'Seems Memcache not installed, please install it to perform tests';
}
コード例 #2
0
 public function showFilteredPetMateList($filterPetMateList)
 {
     $this->data = array();
     $categories = array();
     $breeds = array();
     $ages = array();
     $genders = array();
     $email = $filterPetMateList->getEmail();
     $categories = json_decode($filterPetMateList->getFilterSelectedCategories());
     $breeds = json_decode($filterPetMateList->getFilterSelectedBreeds());
     $ages = json_decode($filterPetMateList->getFilterSelectedAge());
     $genders = json_decode($filterPetMateList->getFilterSelectedGender());
     $sqlAddress = "SELECT latitude,longitude FROM userDetails WHERE email='" . $filterPetMateList->getEmail() . "' ";
     $latlong = mysqli_query($this->con, $sqlAddress);
     $latLongValue = mysqli_fetch_row($latlong);
     $latitude = $latLongValue[0];
     $longitude = $latLongValue[1];
     if ((int) $filterPetMateList->getCurrentPage() == 1) {
         if (empty($categories) && empty($ages)) {
             foreach ($genders as $gender) {
                 $gender = trim($gender);
                 $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                 $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                            FROM petmate pm \n                            INNER JOIN userDetails ud\n                            ON pm.email = ud.email\n                            WHERE pet_gender='{$gender}'\n                            HAVING distance < 5 ORDER BY distance ";
                 try {
                     $select = mysqli_query($this->con, $sql);
                     while ($rowdata = mysqli_fetch_assoc($select)) {
                         $this->data[] = $rowdata;
                     }
                 } catch (Exception $e) {
                     echo 'SQL Exception: ' . $e->getMessage();
                 }
             }
         } else {
             if (empty($categories) && empty($genders)) {
                 $minAge = $ages[0];
                 $maxAge = $ages[1];
                 $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                 $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                        FROM petmate pm \n                        INNER JOIN userDetails ud\n                        ON pm.email = ud.email\n                        WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge}\n                        HAVING distance < 5 ORDER BY distance ";
                 try {
                     $select = mysqli_query($this->con, $sql);
                     while ($rowdata = mysqli_fetch_assoc($select)) {
                         $this->data[] = $rowdata;
                     }
                 } catch (Exception $e) {
                     echo 'SQL Exception: ' . $e->getMessage();
                 }
             } else {
                 if (empty($ages) && empty($genders)) {
                     foreach ($categories as $category) {
                         $category = trim($category);
                         if (empty($breeds)) {
                             $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                             $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                FROM petmate pm \n                                INNER JOIN userDetails ud\n                                ON pm.email = ud.email\n                                WHERE pet_category='{$category}'\n                                HAVING distance < 5 ORDER BY distance ";
                             try {
                                 $select = mysqli_query($this->con, $sql);
                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                     $this->data[] = $rowdata;
                                 }
                             } catch (Exception $e) {
                                 echo 'SQL Exception: ' . $e->getMessage();
                             }
                         } else {
                             foreach ($breeds as $breed) {
                                 $breed = trim($breed);
                                 $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                 $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                    FROM petmate pm \n                                    INNER JOIN userDetails ud\n                                    ON pm.email = ud.email\n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}'\n                                    HAVING distance < 5 ORDER BY distance ";
                                 try {
                                     $select = mysqli_query($this->con, $sql);
                                     while ($rowdata = mysqli_fetch_assoc($select)) {
                                         $this->data[] = $rowdata;
                                     }
                                 } catch (Exception $e) {
                                     echo 'SQL Exception: ' . $e->getMessage();
                                 }
                             }
                         }
                     }
                 } else {
                     if (empty($categories)) {
                         $minAge = $ages[0];
                         $maxAge = $ages[1];
                         foreach ($genders as $gender) {
                             $gender = trim($gender);
                             $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                             $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                            FROM petmate pm \n                            INNER JOIN userDetails ud\n                            ON pm.email = ud.email\n                            WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}'\n                            HAVING distance < 5 ORDER BY distance ";
                             try {
                                 $select = mysqli_query($this->con, $sql);
                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                     $this->data[] = $rowdata;
                                 }
                             } catch (Exception $e) {
                                 echo 'SQL Exception: ' . $e->getMessage();
                             }
                         }
                     } else {
                         if (empty($ages)) {
                             foreach ($categories as $category) {
                                 $category = trim($category);
                                 if (empty($breeds)) {
                                     foreach ($genders as $gender) {
                                         $gender = trim($gender);
                                         $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                         $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                    FROM petmate pm \n                                    INNER JOIN userDetails ud\n                                    ON pm.email = ud.email\n                                    WHERE pet_category='{$category}' AND pet_gender='{$gender}'\n                                    HAVING distance < 5 ORDER BY distance ";
                                         try {
                                             $select = mysqli_query($this->con, $sql);
                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                 $this->data[] = $rowdata;
                                             }
                                         } catch (Exception $e) {
                                             echo 'SQL Exception: ' . $e->getMessage();
                                         }
                                     }
                                 } else {
                                     foreach ($breeds as $breed) {
                                         $breed = trim($breed);
                                         foreach ($genders as $gender) {
                                             $gender = trim($gender);
                                             $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                             $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                        FROM petmate pm \n                                        INNER JOIN userDetails ud\n                                        ON pm.email = ud.email\n                                        WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_gender='{$gender}'\n                                        HAVING distance < 5 ORDER BY distance ";
                                             try {
                                                 $select = mysqli_query($this->con, $sql);
                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                     $this->data[] = $rowdata;
                                                 }
                                             } catch (Exception $e) {
                                                 echo 'SQL Exception: ' . $e->getMessage();
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             if (empty($genders)) {
                                 $minAge = $ages[0];
                                 $maxAge = $ages[1];
                                 foreach ($categories as $category) {
                                     $category = trim($category);
                                     if (empty($breeds)) {
                                         $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                         $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                FROM petmate pm \n                                INNER JOIN userDetails ud\n                                ON pm.email = ud.email\n                                WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge}\n                                HAVING distance < 5 ORDER BY distance ";
                                         try {
                                             $select = mysqli_query($this->con, $sql);
                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                 $this->data[] = $rowdata;
                                             }
                                         } catch (Exception $e) {
                                             echo 'SQL Exception: ' . $e->getMessage();
                                         }
                                     } else {
                                         foreach ($breeds as $breed) {
                                             $breed = trim($breed);
                                             $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                             $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                    FROM petmate pm \n                                    INNER JOIN userDetails ud\n                                    ON pm.email = ud.email\n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge}\n                                    HAVING distance < 5 ORDER BY distance ";
                                             try {
                                                 $select = mysqli_query($this->con, $sql);
                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                     $this->data[] = $rowdata;
                                                 }
                                             } catch (Exception $e) {
                                                 echo 'SQL Exception: ' . $e->getMessage();
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 $minAge = $ages[0];
                                 $maxAge = $ages[1];
                                 if (empty($breeds)) {
                                     foreach ($categories as $category) {
                                         $category = trim($category);
                                         foreach ($genders as $gender) {
                                             $gender = trim($gender);
                                             $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                             $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                    FROM petmate pm \n                                    INNER JOIN userDetails ud\n                                    ON pm.email = ud.email\n                                    WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}'\n                                    HAVING distance < 5 ORDER BY distance ";
                                             try {
                                                 $select = mysqli_query($this->con, $sql);
                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                     $this->data[] = $rowdata;
                                                 }
                                             } catch (Exception $e) {
                                                 echo 'SQL Exception: ' . $e->getMessage();
                                             }
                                         }
                                     }
                                 } else {
                                     foreach ($categories as $category) {
                                         $category = trim($category);
                                         foreach ($breeds as $breed) {
                                             $breed = trim($breed);
                                             foreach ($genders as $gender) {
                                                 $gender = trim($gender);
                                                 $this->con->options(MYSQLI_OPT_CONNECT_TIMEOUT, 500);
                                                 $sql = "SELECT pm.id, pm.first_image_path, pm.second_image_path, pm.third_image_path, pm.pet_category, pm.pet_breed, pm.pet_age_inMonth, pm.pet_age_inYear, pm.pet_gender, pm.pet_description, pm.post_date,ud.name,ud.email,ud.mobileno,( 3959 * acos( cos( radians('{$latitude}') ) * cos( radians( ud.latitude ) ) * cos( radians( ud.longitude ) - radians('{$longitude}') ) + sin( radians('{$latitude}') ) * sin( radians( ud.latitude ) ) ) ) * 1.609344 AS distance\n                                        FROM petmate pm \n                                        INNER JOIN userDetails ud\n                                        ON pm.email = ud.email\n                                        WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}'\n                                        HAVING distance < 5 ORDER BY distance ";
                                                 try {
                                                     $select = mysqli_query($this->con, $sql);
                                                     while ($rowdata = mysqli_fetch_assoc($select)) {
                                                         $this->data[] = $rowdata;
                                                     }
                                                 } catch (Exception $e) {
                                                     echo 'SQL Exception: ' . $e->getMessage();
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $count = 0;
         $count += count($this->data);
         $rowsPerPage = 10;
         $totalPages = ceil($count / $rowsPerPage);
         if (is_numeric($filterPetMateList->getCurrentPage())) {
             $currentPage = (int) $filterPetMateList->getCurrentPage();
         }
         if ($currentPage >= 1 && $currentPage <= $totalPages) {
             $offset = ($currentPage - 1) * $rowsPerPage;
             $formattedArray = array();
             foreach ($this->data as $key => $row) {
                 $formattedArray[$key] = $row['post_date'];
             }
             array_multisort($formattedArray, SORT_DESC, $this->data);
             $output = array_slice($this->data, $offset, $rowsPerPage);
             $cache = new CacheMemcache();
             if ($cache->memcacheEnabled) {
                 $cache->setData('filter_pet_mate_list_email', $email);
                 $cache->setData('filter_pet_mate_list_array_' + $email, $this->data);
                 // saving data to cache server
             }
         }
     } else {
         $cache = new CacheMemcache();
         $output = null;
         if ($cache->memcacheEnabled) {
             if ($email == $cache->getData('filter_pet_mate_list_email')) {
                 $this->data = $cache->getData('filter_pet_mate_list_array_' + $email);
                 $count = 0;
                 $count += count($this->data);
                 $rowsPerPage = 10;
                 $totalPages = ceil($count / $rowsPerPage);
                 if (is_numeric($filterPetMateList->getCurrentPage())) {
                     $currentPage = (int) $filterPetMateList->getCurrentPage();
                 }
                 if ($currentPage >= 1 && $currentPage <= $totalPages) {
                     $offset = ($currentPage - 1) * $rowsPerPage;
                     $output = array_slice($this->data, $offset, $rowsPerPage);
                 }
             }
         }
     }
     return $output;
 }
コード例 #3
0
 public function showFilteredPetList($filterPetList)
 {
     $this->data = array();
     $categories = array();
     $breeds = array();
     $ages = array();
     $genders = array();
     $adoptionAndPrices = array();
     $email = $filterPetList->getEmail();
     $categories = json_decode($filterPetList->getFilterSelectedCategories());
     $breeds = json_decode($filterPetList->getFilterSelectedBreeds());
     $ages = json_decode($filterPetList->getFilterSelectedAge());
     $genders = json_decode($filterPetList->getFilterSelectedGender());
     $adoptionAndPrices = json_decode($filterPetList->getFilterSelectedAdoptionAndPrice());
     if ((int) $filterPetList->getCurrentPage() == 1) {
         if (empty($categories) && empty($ages) && empty($genders)) {
             foreach ($adoptionAndPrices as $adoptionAndPrice) {
                 $adoptionAndPrice = trim($adoptionAndPrice);
                 if ($adoptionAndPrice == "For Adoption") {
                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                FROM petapp p\n                                INNER JOIN userDetails ud\n                                ON p.email = ud.email\n                                WHERE pet_adoption='{$adoptionAndPrice}' ";
                 } else {
                     if ($adoptionAndPrice == "50000 Onwards") {
                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                FROM petapp p\n                                INNER JOIN userDetails ud\n                                ON p.email = ud.email \n                                WHERE pet_price >= 50000 ";
                     } else {
                         $splitPrice = explode("-", $adoptionAndPrice);
                         $minPrice = trim($splitPrice[0]);
                         $maxPrice = trim($splitPrice[1]);
                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                FROM petapp p\n                                INNER JOIN userDetails ud\n                                ON p.email = ud.email\n                                WHERE pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                     }
                 }
                 try {
                     $select = mysqli_query($this->con, $sql);
                     while ($rowdata = mysqli_fetch_assoc($select)) {
                         $this->data[] = $rowdata;
                     }
                 } catch (Exception $e) {
                     echo 'SQL Exception: ' . $e->getMessage();
                 }
             }
         } else {
             if (empty($categories) && empty($ages) && empty($adoptionAndPrices)) {
                 foreach ($genders as $gender) {
                     $gender = trim($gender);
                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                            FROM petapp p\n                            INNER JOIN userDetails ud\n                            ON p.email = ud.email\n                            WHERE pet_gender='{$gender}' ";
                     try {
                         $select = mysqli_query($this->con, $sql);
                         while ($rowdata = mysqli_fetch_assoc($select)) {
                             $this->data[] = $rowdata;
                         }
                     } catch (Exception $e) {
                         echo 'SQL Exception: ' . $e->getMessage();
                     }
                 }
             } else {
                 if (empty($categories) && empty($genders) && empty($adoptionAndPrices)) {
                     $minAge = $ages[0];
                     $maxAge = $ages[1];
                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                        FROM petapp p\n                        INNER JOIN userDetails ud\n                        ON p.email = ud.email\n                        WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} ";
                     try {
                         $select = mysqli_query($this->con, $sql);
                         while ($rowdata = mysqli_fetch_assoc($select)) {
                             $this->data[] = $rowdata;
                         }
                     } catch (Exception $e) {
                         echo 'SQL Exception: ' . $e->getMessage();
                     }
                 } else {
                     if (empty($ages) && empty($genders) && empty($adoptionAndPrices)) {
                         foreach ($categories as $category) {
                             $category = trim($category);
                             if (empty($breeds)) {
                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                FROM petapp p\n                                INNER JOIN userDetails ud\n                                ON p.email = ud.email\n                                WHERE pet_category='{$category}' ";
                                 try {
                                     $select = mysqli_query($this->con, $sql);
                                     while ($rowdata = mysqli_fetch_assoc($select)) {
                                         $this->data[] = $rowdata;
                                     }
                                 } catch (Exception $e) {
                                     echo 'SQL Exception: ' . $e->getMessage();
                                 }
                             } else {
                                 foreach ($breeds as $breed) {
                                     $breed = trim($breed);
                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email\n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}' ";
                                     try {
                                         $select = mysqli_query($this->con, $sql);
                                         while ($rowdata = mysqli_fetch_assoc($select)) {
                                             $this->data[] = $rowdata;
                                         }
                                     } catch (Exception $e) {
                                         echo 'SQL Exception: ' . $e->getMessage();
                                     }
                                 }
                             }
                         }
                     } else {
                         if (empty($categories) && empty($ages)) {
                             foreach ($genders as $gender) {
                                 $gender = trim($gender);
                                 foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                     $adoptionAndPrice = trim($adoptionAndPrice);
                                     if ($adoptionAndPrice == "For Adoption") {
                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email\n                                    WHERE pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                     } else {
                                         if ($adoptionAndPrice == "50000 Onwards") {
                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_gender='{$gender}' AND pet_price >= 50000 ";
                                         } else {
                                             $splitPrice = explode("-", $adoptionAndPrice);
                                             $minPrice = trim($splitPrice[0]);
                                             $maxPrice = trim($splitPrice[1]);
                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email\n                                    WHERE pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                         }
                                     }
                                     try {
                                         $select = mysqli_query($this->con, $sql);
                                         while ($rowdata = mysqli_fetch_assoc($select)) {
                                             $this->data[] = $rowdata;
                                         }
                                     } catch (Exception $e) {
                                         echo 'SQL Exception: ' . $e->getMessage();
                                     }
                                 }
                             }
                         } else {
                             if (empty($categories) && empty($genders)) {
                                 $minAge = $ages[0];
                                 $maxAge = $ages[1];
                                 foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                     $adoptionAndPrice = trim($adoptionAndPrice);
                                     if ($adoptionAndPrice == "For Adoption") {
                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                            FROM petapp p\n                            INNER JOIN userDetails ud\n                            ON p.email = ud.email\n                            WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_adoption='{$adoptionAndPrice}' ";
                                     } else {
                                         if ($adoptionAndPrice == "50000 Onwards") {
                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                            FROM petapp p\n                            INNER JOIN userDetails ud\n                            ON p.email = ud.email \n                            WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price >= 50000 ";
                                         } else {
                                             $splitPrice = explode("-", $adoptionAndPrice);
                                             $minPrice = trim($splitPrice[0]);
                                             $maxPrice = trim($splitPrice[1]);
                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                            FROM petapp p\n                            INNER JOIN userDetails ud\n                            ON p.email = ud.email\n                            WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                         }
                                     }
                                     try {
                                         $select = mysqli_query($this->con, $sql);
                                         while ($rowdata = mysqli_fetch_assoc($select)) {
                                             $this->data[] = $rowdata;
                                         }
                                     } catch (Exception $e) {
                                         echo 'SQL Exception: ' . $e->getMessage();
                                     }
                                 }
                             } else {
                                 if (empty($categories) && empty($adoptionAndPrices)) {
                                     $minAge = $ages[0];
                                     $maxAge = $ages[1];
                                     foreach ($genders as $gender) {
                                         $gender = trim($gender);
                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                            FROM petapp p\n                            INNER JOIN userDetails ud\n                            ON p.email = ud.email\n                            WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' ";
                                         try {
                                             $select = mysqli_query($this->con, $sql);
                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                 $this->data[] = $rowdata;
                                             }
                                         } catch (Exception $e) {
                                             echo 'SQL Exception: ' . $e->getMessage();
                                         }
                                     }
                                 } else {
                                     if (empty($ages) && empty($genders)) {
                                         if (empty($breeds)) {
                                             foreach ($categories as $category) {
                                                 $category = trim($category);
                                                 foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                     $adoptionAndPrice = trim($adoptionAndPrice);
                                                     if ($adoptionAndPrice == "For Adoption") {
                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                        FROM petapp p\n                                        INNER JOIN userDetails ud\n                                        ON p.email = ud.email\n                                        WHERE pet_category='{$category}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                     } else {
                                                         if ($adoptionAndPrice == "50000 Onwards") {
                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                        FROM petapp p\n                                        INNER JOIN userDetails ud\n                                        ON p.email = ud.email \n                                        WHERE pet_category='{$category}' AND pet_price >= 50000 ";
                                                         } else {
                                                             $splitPrice = explode("-", $adoptionAndPrice);
                                                             $minPrice = trim($splitPrice[0]);
                                                             $maxPrice = trim($splitPrice[1]);
                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                        FROM petapp p\n                                        INNER JOIN userDetails ud\n                                        ON p.email = ud.email\n                                        WHERE pet_category='{$category}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                         }
                                                     }
                                                     try {
                                                         $select = mysqli_query($this->con, $sql);
                                                         while ($rowdata = mysqli_fetch_assoc($select)) {
                                                             $this->data[] = $rowdata;
                                                         }
                                                     } catch (Exception $e) {
                                                         echo 'SQL Exception: ' . $e->getMessage();
                                                     }
                                                 }
                                             }
                                         } else {
                                             foreach ($categories as $category) {
                                                 $category = trim($category);
                                                 foreach ($breeds as $breed) {
                                                     $breed = trim($breed);
                                                     foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                         $adoptionAndPrice = trim($adoptionAndPrice);
                                                         if ($adoptionAndPrice == "For Adoption") {
                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                         } else {
                                                             if ($adoptionAndPrice == "50000 Onwards") {
                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email \n                                            WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_price >= 50000 ";
                                                             } else {
                                                                 $splitPrice = explode("-", $adoptionAndPrice);
                                                                 $minPrice = trim($splitPrice[0]);
                                                                 $maxPrice = trim($splitPrice[1]);
                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                             }
                                                         }
                                                         try {
                                                             $select = mysqli_query($this->con, $sql);
                                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                 $this->data[] = $rowdata;
                                                             }
                                                         } catch (Exception $e) {
                                                             echo 'SQL Exception: ' . $e->getMessage();
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     } else {
                                         if (empty($ages) && empty($adoptionAndPrices)) {
                                             if (empty($breeds)) {
                                                 foreach ($categories as $category) {
                                                     $category = trim($category);
                                                     foreach ($genders as $gender) {
                                                         $gender = trim($gender);
                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_category='{$category}' AND pet_gender='{$gender}' ";
                                                         try {
                                                             $select = mysqli_query($this->con, $sql);
                                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                 $this->data[] = $rowdata;
                                                             }
                                                         } catch (Exception $e) {
                                                             echo 'SQL Exception: ' . $e->getMessage();
                                                         }
                                                     }
                                                 }
                                             } else {
                                                 foreach ($categories as $category) {
                                                     $category = trim($category);
                                                     foreach ($breeds as $breed) {
                                                         $breed = trim($breed);
                                                         foreach ($genders as $gender) {
                                                             $gender = trim($gender);
                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_gender='{$gender}' ";
                                                             try {
                                                                 $select = mysqli_query($this->con, $sql);
                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                     $this->data[] = $rowdata;
                                                                 }
                                                             } catch (Exception $e) {
                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         } else {
                                             if (empty($genders) && empty($adoptionAndPrices)) {
                                                 $minAge = $ages[0];
                                                 $maxAge = $ages[1];
                                                 if (empty($breeds)) {
                                                     foreach ($categories as $category) {
                                                         $category = trim($category);
                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                FROM petapp p\n                                INNER JOIN userDetails ud\n                                ON p.email = ud.email \n                                WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} ";
                                                         try {
                                                             $select = mysqli_query($this->con, $sql);
                                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                 $this->data[] = $rowdata;
                                                             }
                                                         } catch (Exception $e) {
                                                             echo 'SQL Exception: ' . $e->getMessage();
                                                         }
                                                     }
                                                 } else {
                                                     foreach ($categories as $category) {
                                                         $category = trim($category);
                                                         foreach ($breeds as $breed) {
                                                             $breed = trim($breed);
                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} ";
                                                             try {
                                                                 $select = mysqli_query($this->con, $sql);
                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                     $this->data[] = $rowdata;
                                                                 }
                                                             } catch (Exception $e) {
                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                             }
                                                         }
                                                     }
                                                 }
                                             } else {
                                                 if (empty($categories)) {
                                                     $minAge = $ages[0];
                                                     $maxAge = $ages[1];
                                                     foreach ($genders as $gender) {
                                                         $gender = trim($gender);
                                                         foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                             $adoptionAndPrice = trim($adoptionAndPrice);
                                                             if ($adoptionAndPrice == "For Adoption") {
                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email\n                                    WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                             } else {
                                                                 if ($adoptionAndPrice == "50000 Onwards") {
                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price >= 50000 ";
                                                                 } else {
                                                                     $splitPrice = explode("-", $adoptionAndPrice);
                                                                     $minPrice = trim($splitPrice[0]);
                                                                     $maxPrice = trim($splitPrice[1]);
                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email\n                                    WHERE pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                 }
                                                             }
                                                             try {
                                                                 $select = mysqli_query($this->con, $sql);
                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                     $this->data[] = $rowdata;
                                                                 }
                                                             } catch (Exception $e) {
                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if (empty($ages)) {
                                                         if (empty($breeds)) {
                                                             foreach ($categories as $category) {
                                                                 $category = trim($category);
                                                                 foreach ($genders as $gender) {
                                                                     $gender = trim($gender);
                                                                     foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                         $adoptionAndPrice = trim($adoptionAndPrice);
                                                                         if ($adoptionAndPrice == "For Adoption") {
                                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                                         } else {
                                                                             if ($adoptionAndPrice == "50000 Onwards") {
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email \n                                            WHERE pet_category='{$category}' AND pet_gender='{$gender}' AND pet_price >= 50000 ";
                                                                             } else {
                                                                                 $splitPrice = explode("-", $adoptionAndPrice);
                                                                                 $minPrice = trim($splitPrice[0]);
                                                                                 $maxPrice = trim($splitPrice[1]);
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                             }
                                                                         }
                                                                         try {
                                                                             $select = mysqli_query($this->con, $sql);
                                                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                 $this->data[] = $rowdata;
                                                                             }
                                                                         } catch (Exception $e) {
                                                                             echo 'SQL Exception: ' . $e->getMessage();
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         } else {
                                                             foreach ($categories as $category) {
                                                                 $category = trim($category);
                                                                 foreach ($breeds as $breed) {
                                                                     $breed = trim($breed);
                                                                     foreach ($genders as $gender) {
                                                                         $gender = trim($gender);
                                                                         foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                             $adoptionAndPrice = trim($adoptionAndPrice);
                                                                             if ($adoptionAndPrice == "For Adoption") {
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                                             } else {
                                                                                 if ($adoptionAndPrice == "50000 Onwards") {
                                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email \n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_gender='{$gender}' AND pet_price >= 50000 ";
                                                                                 } else {
                                                                                     $splitPrice = explode("-", $adoptionAndPrice);
                                                                                     $minPrice = trim($splitPrice[0]);
                                                                                     $maxPrice = trim($splitPrice[1]);
                                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                                 }
                                                                             }
                                                                             try {
                                                                                 $select = mysqli_query($this->con, $sql);
                                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                     $this->data[] = $rowdata;
                                                                                 }
                                                                             } catch (Exception $e) {
                                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     } else {
                                                         if (empty($genders)) {
                                                             $minAge = $ages[0];
                                                             $maxAge = $ages[1];
                                                             if (empty($breeds)) {
                                                                 foreach ($categories as $category) {
                                                                     $category = trim($category);
                                                                     foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                         $adoptionAndPrice = trim($adoptionAndPrice);
                                                                         if ($adoptionAndPrice == "For Adoption") {
                                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_adoption='{$adoptionAndPrice}' ";
                                                                         } else {
                                                                             if ($adoptionAndPrice == "50000 Onwards") {
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email \n                                            WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price >= 50000 ";
                                                                             } else {
                                                                                 $splitPrice = explode("-", $adoptionAndPrice);
                                                                                 $minPrice = trim($splitPrice[0]);
                                                                                 $maxPrice = trim($splitPrice[1]);
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                            FROM petapp p\n                                            INNER JOIN userDetails ud\n                                            ON p.email = ud.email\n                                            WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                             }
                                                                         }
                                                                         try {
                                                                             $select = mysqli_query($this->con, $sql);
                                                                             while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                 $this->data[] = $rowdata;
                                                                             }
                                                                         } catch (Exception $e) {
                                                                             echo 'SQL Exception: ' . $e->getMessage();
                                                                         }
                                                                     }
                                                                 }
                                                             } else {
                                                                 foreach ($categories as $category) {
                                                                     $category = trim($category);
                                                                     foreach ($breeds as $breed) {
                                                                         $breed = trim($breed);
                                                                         foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                             $adoptionAndPrice = trim($adoptionAndPrice);
                                                                             if ($adoptionAndPrice == "For Adoption") {
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_adoption='{$adoptionAndPrice}' ";
                                                                             } else {
                                                                                 if ($adoptionAndPrice == "50000 Onwards") {
                                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email \n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price >= 50000 ";
                                                                                 } else {
                                                                                     $splitPrice = explode("-", $adoptionAndPrice);
                                                                                     $minPrice = trim($splitPrice[0]);
                                                                                     $maxPrice = trim($splitPrice[1]);
                                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                                 }
                                                                             }
                                                                             try {
                                                                                 $select = mysqli_query($this->con, $sql);
                                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                     $this->data[] = $rowdata;
                                                                                 }
                                                                             } catch (Exception $e) {
                                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         } else {
                                                             if (empty($adoptionAndPrices)) {
                                                                 $minAge = $ages[0];
                                                                 $maxAge = $ages[1];
                                                                 if (empty($breeds)) {
                                                                     foreach ($categories as $category) {
                                                                         $category = trim($category);
                                                                         foreach ($genders as $gender) {
                                                                             $gender = trim($gender);
                                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}'  ";
                                                                             try {
                                                                                 $select = mysqli_query($this->con, $sql);
                                                                                 while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                     $this->data[] = $rowdata;
                                                                                 }
                                                                             } catch (Exception $e) {
                                                                                 echo 'SQL Exception: ' . $e->getMessage();
                                                                             }
                                                                         }
                                                                     }
                                                                 } else {
                                                                     foreach ($categories as $category) {
                                                                         $category = trim($category);
                                                                         foreach ($breeds as $breed) {
                                                                             $breed = trim($breed);
                                                                             foreach ($genders as $gender) {
                                                                                 $gender = trim($gender);
                                                                                 $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                    FROM petapp p\n                                    INNER JOIN userDetails ud\n                                    ON p.email = ud.email \n                                    WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}'  ";
                                                                                 try {
                                                                                     $select = mysqli_query($this->con, $sql);
                                                                                     while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                         $this->data[] = $rowdata;
                                                                                     }
                                                                                 } catch (Exception $e) {
                                                                                     echo 'SQL Exception: ' . $e->getMessage();
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             } else {
                                                                 $minAge = $ages[0];
                                                                 $maxAge = $ages[1];
                                                                 if (empty($breeds)) {
                                                                     foreach ($categories as $category) {
                                                                         $category = trim($category);
                                                                         foreach ($genders as $gender) {
                                                                             $gender = trim($gender);
                                                                             foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                                 $adoptionAndPrice = trim($adoptionAndPrice);
                                                                                 if ($adoptionAndPrice == "For Adoption") {
                                                                                     $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                                                 } else {
                                                                                     if ($adoptionAndPrice == "50000 Onwards") {
                                                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email \n                                                WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price >= 50000 ";
                                                                                     } else {
                                                                                         $splitPrice = explode("-", $adoptionAndPrice);
                                                                                         $minPrice = trim($splitPrice[0]);
                                                                                         $maxPrice = trim($splitPrice[1]);
                                                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                                     }
                                                                                 }
                                                                                 try {
                                                                                     $select = mysqli_query($this->con, $sql);
                                                                                     while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                         $this->data[] = $rowdata;
                                                                                     }
                                                                                 } catch (Exception $e) {
                                                                                     echo 'SQL Exception: ' . $e->getMessage();
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 } else {
                                                                     foreach ($categories as $category) {
                                                                         $category = trim($category);
                                                                         foreach ($breeds as $breed) {
                                                                             $breed = trim($breed);
                                                                             foreach ($genders as $gender) {
                                                                                 $gender = trim($gender);
                                                                                 foreach ($adoptionAndPrices as $adoptionAndPrice) {
                                                                                     $adoptionAndPrice = trim($adoptionAndPrice);
                                                                                     if ($adoptionAndPrice == "For Adoption") {
                                                                                         $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_adoption='{$adoptionAndPrice}' ";
                                                                                     } else {
                                                                                         if ($adoptionAndPrice == "50000 Onwards") {
                                                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email \n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price >= 50000 ";
                                                                                         } else {
                                                                                             $splitPrice = explode("-", $adoptionAndPrice);
                                                                                             $minPrice = trim($splitPrice[0]);
                                                                                             $maxPrice = trim($splitPrice[1]);
                                                                                             $sql = "SELECT p.first_image_path, p.second_image_path, p.third_image_path, p.pet_category, p.pet_breed, p.pet_age_inMonth, p.pet_age_inYear, p.pet_gender, p.pet_description, p.pet_adoption, p.pet_price, p.post_date, p.email, ud.name, ud.mobileno \n                                                FROM petapp p\n                                                INNER JOIN userDetails ud\n                                                ON p.email = ud.email\n                                                WHERE pet_category='{$category}' AND pet_breed='{$breed}' AND pet_age_inYear BETWEEN {$minAge} AND {$maxAge} AND pet_gender='{$gender}' AND pet_price BETWEEN {$minPrice} AND {$maxPrice} ";
                                                                                         }
                                                                                     }
                                                                                     try {
                                                                                         $select = mysqli_query($this->con, $sql);
                                                                                         while ($rowdata = mysqli_fetch_assoc($select)) {
                                                                                             $this->data[] = $rowdata;
                                                                                         }
                                                                                     } catch (Exception $e) {
                                                                                         echo 'SQL Exception: ' . $e->getMessage();
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $count = 0;
         $count += count($this->data);
         $rowsPerPage = 10;
         $totalPages = ceil($count / $rowsPerPage);
         if (is_numeric($filterPetList->getCurrentPage())) {
             $currentPage = (int) $filterPetList->getCurrentPage();
         }
         if ($currentPage >= 1 && $currentPage <= $totalPages) {
             $offset = ($currentPage - 1) * $rowsPerPage;
             $formattedArray = array();
             foreach ($this->data as $key => $row) {
                 $formattedArray[$key] = $row['post_date'];
             }
             array_multisort($formattedArray, SORT_DESC, $this->data);
             $output = array_slice($this->data, $offset, $rowsPerPage);
             $cache = new CacheMemcache();
             if ($cache->memcacheEnabled) {
                 $cache->setData('filter_pet_list_email', $email);
                 $cache->setData('filter_pet_list_array_' + $email, $this->data);
                 // saving data to cache server
             }
         }
     } else {
         $cache = new CacheMemcache();
         if ($cache->memcacheEnabled) {
             if ($email == $cache->getData('filter_pet_list_email')) {
                 $this->data = $cache->getData('filter_pet_list_array_' + $email);
                 $count = 0;
                 $count += count($this->data);
                 $rowsPerPage = 10;
                 $totalPages = ceil($count / $rowsPerPage);
                 if (is_numeric($filterPetList->getCurrentPage())) {
                     $currentPage = (int) $filterPetList->getCurrentPage();
                 }
                 if ($currentPage >= 1 && $currentPage <= $totalPages) {
                     $offset = ($currentPage - 1) * $rowsPerPage;
                     $output = array_slice($this->data, $offset, $rowsPerPage);
                 }
             }
         }
     }
     return $output;
 }