コード例 #1
0
ファイル: con_pagination.php プロジェクト: ITAAcademy/tipsops
    $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
    $dataBack = array('numPage' => $numPage, 'articleList' => $articleList);
    $dataBack = json_encode($dataBack);
    echo $dataBack;
}
コード例 #2
0
<?php

/**
 * User: Ivan Pirus
 * Group: B14
 * Date: 06.02.2016
 * Time: 0:27
 */
if ($_GET['type']) {
    include 'con_cookie.php';
    $type = GetCookieWord('language_search');
    $SEARCH_PAGINATION = 4;
    $LANGUAGE_PAGINATION = 10;
    $result = 0;
    if ($type == 'search') {
        $result = $SEARCH_PAGINATION;
    } else {
        if ($type == 'language') {
            $result = $LANGUAGE_PAGINATION;
        }
    }
    echo $result;
} else {
    die("No, GET");
}