Example #1
0
function search_handler($query, $config)
{
    $result = 0;
    $stand = 32;
    $lim1 = 0;
    $lim2 = 32;
    extract($query);
    if (isset($p)) {
        if ($p != '1') {
            $lim1 = $stand * ($p - 1);
            $lim2 = $lim1 + $stand;
        }
    }
    $sear = new search(new dbc($config), $filterby);
    $products = new product(new dbc($config));
    //new search
    if (isset($search1)) {
        if (empty($searchkey1)) {
            if ($sub_category == '*' && $supplier == '*') {
                $count = $sear->count_new_pro_list();
                $result = $sear->search10_subcat10_supp10($lim1, $lim2);
            }
            if ($sub_category != '*' && $supplier == '*') {
                $count = $sear->count_search10_subcat11_supp10($sub_category);
                $result = $sear->search10_subcat11_supp10($sub_category, $lim1, $lim2);
            }
            if ($sub_category == '*' && $supplier != '*') {
                $count = $sear->count_search10_subcat10_supp11($supplier);
                $result = $sear->search10_subcat10_supp11($supplier, $lim1, $lim2);
            }
            if ($sub_category != '*' && $supplier != '*') {
                $count = $sear->count_search10_subcat11_supp11($sub_category, $supplier);
                $result = $sear->search10_subcat11_supp11($sub_category, $supplier, $lim1, $lim2);
            }
        }
        //active search
        if (!empty($searchkey1)) {
            if ($sub_category == '*' && $supplier == '*') {
                $count = $sear->count_search11_subcat10_supp10($searchkey1);
                $result = $sear->search11_subcat10_supp10($searchkey1, $lim1, $lim2);
            }
            if ($sub_category != '*' && $supplier == '*') {
                $count = $sear->count_search11_subcat11_supp10($sub_category, $searchkey1);
                $result = $sear->search11_subcat11_supp10($sub_category, $searchkey1, $lim1, $lim2);
            }
            if ($sub_category == '*' && $supplier != '*') {
                $count = $sear->count_search11_subcat10_supp11($supplier, $searchkey1);
                $result = $sear->search11_subcat10_supp11($supplier, $searchkey1, $lim1, $lim2);
            }
            if ($sub_category != '*' && $supplier != '*') {
                $count = $sear->count_search11_subcat11_supp11($sub_category, $supplier, $searchkey1);
                $result = $sear->search11_subcat11_supp11($sub_category, $supplier, $searchkey1, $lim1, $lim2);
            }
        }
    }
    if (isset($search2)) {
        if (empty($searchkey2)) {
            if ($category == '*' && $supplier == '*') {
                $count = $sear->count_active_pro_list();
                $result = $sear->search20_subcat20_supp20($lim1, $lim2);
            }
            if ($category != '*' && $supplier == '*') {
                $count = $sear->count_search20_subcat21_supp20($category);
                $result = $sear->search20_subcat21_supp20($category, $lim1, $lim2);
            }
            if ($category == '*' && $supplier != '*') {
                $count = $sear->count_search20_subcat20_supp21($supplier);
                $result = $sear->search20_subcat20_supp21($supplier, $lim1, $lim2);
            }
            if ($category != '*' && $supplier != '*') {
                $count = $sear->count_search20_subcat21_supp21($category, $supplier);
                $result = $sear->search20_subcat21_supp21($category, $supplier, $lim1, $lim2);
            }
        }
        if (!empty($searchkey2)) {
            if ($category == '*' && $supplier == '*') {
                $count = $sear->count_search21_subcat20_supp20($searchkey2);
                $result = $sear->search21_subcat20_supp20($searchkey2, $lim1, $lim2);
            }
            if ($category != '*' && $supplier == '*') {
                $count = $sear->count_search21_subcat21_supp20($category, $searchkey2);
                $result = $sear->search21_subcat21_supp20($category, $searchkey2, $lim1, $lim2);
            }
            if ($category == '*' && $supplier != '*') {
                $count = $sear->count_search21_subcat20_supp21($supplier, $searchkey2);
                $result = $sear->search21_subcat20_supp21($supplier, $searchkey2, $lim1, $lim2);
            }
            if ($category != '*' && $supplier != '*') {
                $count = $sear->count_search21_subcat21_supp21($category, $supplier, $searchkey2);
                $result = $sear->search21_subcat21_supp21($category, $supplier, $searchkey2, $lim1, $lim2);
            }
        }
    }
    //archived search
    if (isset($search3)) {
        if (empty($searchkey3)) {
            if ($category == '*' && $supplier == '*') {
                $count = $sear->count_archived_pro_list();
                $result = $sear->search30_subcat30_supp30($lim1, $lim2);
            }
            if ($category != '*' && $supplier == '*') {
                $count = $sear->count_search30_subcat31_supp30($category);
                $result = $sear->search30_subcat31_supp30($category, $lim1, $lim2);
            }
            if ($category == '*' && $supplier != '*') {
                $count = $sear->count_search30_subcat30_supp31($supplier);
                $result = $sear->search30_subcat30_supp31($supplier, $lim1, $lim2);
            }
            if ($category != '*' && $supplier != '*') {
                $count = $sear->count_search30_subcat31_supp31($category, $supplier);
                $result = $sear->search30_subcat31_supp31($category, $supplier, $lim1, $lim2);
            }
        }
        if (!empty($searchkey3)) {
            if ($category == '*' && $supplier == '*') {
                $count = $sear->count_search31_subcat30_supp30($searchkey3);
                $result = $sear->search31_subcat30_supp30($searchkey3, $lim1, $lim2);
            }
            if ($category != '*' && $supplier == '*') {
                $count = $sear->count_search31_subcat31_supp30($category, $searchkey3);
                $result = $sear->search31_subcat31_supp30($category, $searchkey3, $lim1, $lim2);
            }
            if ($category == '*' && $supplier != '*') {
                $count = $sear->count_search31_subcat30_supp31($supplier, $searchkey3);
                $result = $sear->search31_subcat30_supp31($supplier, $searchkey3, $lim1, $lim2);
            }
            if ($category != '*' && $supplier != '*') {
                $count = $sear->count_search31_subcat31_supp31($category, $supplier, $searchkey3);
                $result = $sear->search31_subcat31_supp31($category, $supplier, $searchkey3, $lim1, $lim2);
            }
        }
    }
    $count = mysqli_fetch_row($count);
    $count = $count[0];
    $noPag = $count / $stand;
    if ($noPag == '0') {
        $noPag = 1;
    }
    if ($noPag == '0') {
        $noPag = 1;
    }
    if ($count < $stand) {
        $noPag = 1;
    } elseif ($count % $stand == true) {
        $noPag += 1;
    }
    if ($count < $lim2) {
        $lim2 = $count;
    }
    return $y = array($result, $count, $lim2, $noPag);
}
Example #2
0
        $count = $sear->count_new_pro_list();
        $count = mysqli_fetch_row($count);
        $count = $count[0];
        $noPag = $count / $stand;
        if ($noPag == '0') {
            $noPag = 1;
        }
        if ($count < $stand) {
            $noPag = 1;
        } elseif ($count % $stand == true) {
            $noPag += 1;
        }
        if ($count < $limit2) {
            $limit2 = $count;
        }
        $result = $sear->search10_subcat10_supp10($limit1, $limit2);
        echo '</form>';
    }
    ?>

<div class="product1">
<?php 
    if (isset($_GET['message1'])) {
        echo '<br>' . $_GET['message1'];
    }
    $product->category_default_view('1');
    echo '<p>' . $limit2 . ' out of ' . $count . " Product.</p>";
    if ($count != 0) {
        echo "\n\t\t    <form action=\"handlers/product.php\" method=\"post\">\n\t\t\t<label>Select all<input type=\"checkbox\" name=\"selectbox\" onclick=\"checkall(this)\" ></label>\n\t\t\t<input type=\"submit\" value=\"Delete Selection\" name=\"delete_selection1\"class=\"button\">\n\t\t\t<input type=\"submit\" value=\"move Selection\" name=\"move_selection1\"class=\"button\">\n\t\t\t<ul class=\"products\">";
        while ($row = mysqli_fetch_assoc($result)) {
            $product->view_single_product($row['pro_id'], $row['product_url'], $row['supp_name'], $row['pro_name'], $row['price'], $row['img_url']);