Esempio n. 1
0
include 'con_cookie.php';
if ($_POST) {
    $page = $_POST['page'];
    // Current page number
    $per_page = $_POST['per_page'];
    // Articles per page
    if ($page != 1) {
        $start = ($page - 1) * $per_page;
    } else {
        $start = 0;
    }
    $language_search = GetCookieWord('language_search');
    switch ($language_search) {
        case 'search':
            $words = GetCookieWord('word');
            $select_search = SearchSelect($words, $start, $per_page);
            // get select with db
            $array_result = SearchResult($select_search);
            //controller get select with db
            $numArticles = GetCookieWord('searched');
            // get numbers result search
            $numPage = ceil($numArticles / $per_page);
            // Total number of page for pagination
            $articleList = PrepareResult($array_result);
            // prepare content article
            break;
        default:
            die("No, language_search");
            return false;
    }
    // We send back the total number of page and the article list
Esempio n. 2
0
include 'con_main_search.php';
include 'controller_main_language.php';
include 'models/select_articles.php';
include 'views/search.php';
include 'views/pagination.php';
include 'con_cookie.php';
if (isset($_GET['key'])) {
    $words = $_GET['key'];
} else {
    die("Nothing is found");
}
if ($words === "") {
    ShowEmpty();
    return;
}
$select_search = SearchSelect($words, 0, 1000);
// get select with db
$array_result = SearchResult($select_search);
//controller get select with db
if ($array_result != false) {
    SaveCookieWord($words, 'word');
    // Save word search in cookie
    UpdateCookieWord('search', 'language_search');
    // Update result look
    //PrepareUpdate($array_result); // update reviews article
    $result = count($array_result);
    // get numbers result search
    DeleteCookieWord('searched');
    SaveCookieWord($result, 'searched');
    ShowNumbers($result);
    // show numbers searched result