當前位置: 首頁>>代碼示例>>PHP>>正文


PHP pagination::setShowFirstAndLast方法代碼示例

本文整理匯總了PHP中pagination::setShowFirstAndLast方法的典型用法代碼示例。如果您正苦於以下問題:PHP pagination::setShowFirstAndLast方法的具體用法?PHP pagination::setShowFirstAndLast怎麽用?PHP pagination::setShowFirstAndLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pagination的用法示例。


在下文中一共展示了pagination::setShowFirstAndLast方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: search_question

function search_question($query, $cid, $count, $page = 1)
{
    //Search questions by post title and post body
    $output = '';
    $uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0;
    $posts = array();
    if (isset($_SESSION['rid']) && $_SESSION['rid'] != 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    } elseif (!isset($_SESSION['rid']) || $_SESSION['rid'] == 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE Post_Current=1 AND (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    }
    if ($result) {
        while ($row = mysql_fetch_assoc($result)) {
            $posts[] = $row;
        }
    }
    if ($cid != 0) {
        $posts = array_filter($posts, array(new Filter($cid), 'filter_cid'));
    }
    usort($posts, 'sort_post_date_descend');
    $pagination = new pagination($posts, $page, $count, 5);
    $pagination->setShowFirstAndLast(true);
    $pagination->setMainSeperator('');
    $posts = $pagination->getResults();
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<div class="posts">';
    for ($i = 0; $i < count($posts); $i++) {
        if (isset($posts[$i])) {
            $pid = $posts[$i]['Post_ID'];
            $output .= view_post($pid, $uid);
            $output .= $i != count($posts) - 1 ? '<hr>' : '';
        }
    }
    $output .= '</div>';
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<script>
				function turnPage(page) {
					$("#feeds").load("triggers/paging_search.php",{count:' . $count . ',cid:' . $cid . ',page:page,keyword:"' . $query . '"});
				}
				</script>';
    if (count($posts) == 0) {
        $output .= '<h3>There is no results for this search criteria.</h3>';
    }
    return $output;
}
開發者ID:khanhnnvn,項目名稱:OKMS,代碼行數:45,代碼來源:functions.inc.php

示例2: array

    <hr  />
      <?php 
ini_set('display_errors', 'On');
error_reporting(E_ALL);
// Include the pagination class
include 'pagination.class.php';
// some example data
foreach (range(1, 200) as $value) {
    $products[] = array('Product' => 'Product ' . $value, 'Price' => rand(100, 1000));
}
// If we have an array with items
if (count($products)) {
    // Create the pagination object
    $pagination = new pagination($products, isset($_GET['page']) ? $_GET['page'] : 1, 15);
    // Decide if the first and last links should show
    $pagination->setShowFirstAndLast(false);
    // You can overwrite the default seperator
    $pagination->setMainSeperator(' | ');
    // Parse through the pagination class
    $productPages = $pagination->getResults();
    // If we have items
    if (count($productPages) != 0) {
        // Create the page numbers
        echo $pageNumbers = '<div class="numbers">' . $pagination->getLinks($_GET) . '</div>';
        // Loop through all the items in the array
        foreach ($productPages as $productArray) {
            // Show the information about the item
            echo '<p><b>' . $productArray['Product'] . '</b> &nbsp; &pound;' . $productArray['Price'] . '</p>';
        }
        // print out the page numbers beneath the results
        echo $pageNumbers;
開發者ID:Providex,項目名稱:php-array-pagination,代碼行數:31,代碼來源:example.php


注:本文中的pagination::setShowFirstAndLast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。