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


PHP Pager::findPages方法代碼示例

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


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

示例1: dopaging

function dopaging($sql, $numrecords = 0, $limit = 15)
{
    global $clspg;
    global $pages;
    global $num;
    $clspg = new Pager();
    $temp = mysql_query($sql) or die(mysql_error());
    $numrows = mysql_num_rows($temp);
    $start = $clspg->findStart($limit, $numrows);
    if ($numrecords == 0) {
        $pages = $clspg->findPages($numrows, $limit);
    } else {
        if ($numrows > $numrecords) {
            $pages = $clspg->findPages($numrecords, $limit);
        } else {
            $pages = $clspg->findPages($numrows, $limit);
        }
    }
    if ($numrecords == 0) {
        $sql1 = $sql . " LIMIT " . $start . ", " . $limit;
    } else {
        if ($start + $limit > $numrecords) {
            $sql1 = $sql . " LIMIT " . $start . ", " . ($numrecords - $start);
        } else {
            $sql1 = $sql . " LIMIT " . $start . ", " . $limit;
        }
    }
    return $sql1;
}
開發者ID:kevinsmasters,項目名稱:purecatskillsmarketplace,代碼行數:29,代碼來源:functions.php

示例2: Pager

error_reporting(E_ALL ^ E_NOTICE);
session_start();
$mysqli = mysqli_connect('localhost', 'root', '', 'bookstore');
mysqli_query($mysqli, "SET NAMES 'utf8'");
$p = new Pager();
// yêu cầu giới hạn bao nhiêu dòng
$limit = 8;
// Tìm dòng bắt đầu đưa vào trang lấy được (khai báo nếu nó chưa có giá trị)
$start = $p->findStart($limit);
// Tìm tổng số dOng với câu lệnh truy vấn
if (isset($_GET["matheloai"])) {
    $query = mysqli_query($mysqli, "SELECT * FROM sach WHERE MaTheLoai = '" . $_GET["matheloai"] . "'");
    $count = mysqli_num_rows($query);
    // Tìm số trang dựa vào số dọng và số giới hạn
    $pages = $p->findPages($count, $limit);
    $sql = "SELECT s.id, s.TuaDe, s.TacGia, s.Gia, s.NhaXuatBan, s.NamXuatBan, s.MaTheLoai,s.ImgSrc, tl.TenTheLoai FROM sach s, theloai tl WHERE s.MaTheLoai = tl.MaTheLoai AND s.MaTheLoai = '" . $_GET["matheloai"] . "' limit " . $start . "," . $limit;
    $sach = "SELECT tl.TenTheLoai, count(s.MaTheLoai) from sach s, theloai tl where s.MaTheLoai = tl.MaTheLoai AND s.MaTheLoai = '" . $_GET["matheloai"] . "' group by tl.TenTheLoai";
    $kq = mysqli_query($mysqli, $sach);
    $so = mysqli_fetch_row($kq);
    $result = mysqli_query($mysqli, $sql);
    if (mysqli_num_rows($result) != 0) {
        echo "<table align='center' width='100%'>";
        echo "<tr style='color:red; font-weight:bold'; align='center' >";
        echo "<td colspan='4' style='background-image:url(../images/danhmuc.png)' height='30'><p style='color:#FFF; font-weight:bold;  text-align:center' >Sách {$so['0']} ({$so['1']} sách)  </p></td>";
        echo "</tr>";
        $stt = 0;
        while ($row = mysqli_fetch_row($result)) {
            if ($stt % 4 == 0) {
                echo "<tr>";
            }
開發者ID:loctho1995,項目名稱:Web-Bookstore,代碼行數:30,代碼來源:ds_sach.php

示例3: getListVoucher

function getListVoucher()
{
    $p = new Pager();
    /* Show many results per page? */
    $limit = 100;
    /* Find the start depending on $_GET['page'] (declared if it's null) */
    $start = $p->findStart($limit);
    /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */
    $count = mysql_num_rows(mysql_query("SELECT * FROM wp_voucher_post"));
    /* Find the number of pages based on $count and $limit */
    $pages = $p->findPages($count, $limit);
    /* Now we use the LIMIT clause to grab a range of rows */
    $result = mysql_query("SELECT * FROM wp_voucher_post LIMIT " . $start . ", " . $limit);
    /* Now get the page list and echo it */
    $pagelist = $p->pageList($_GET['page'], $pages);
    echo $pagelist;
}
開發者ID:vanlong200880,項目名稱:tmdt,代碼行數:17,代碼來源:voucher.php


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