0

我是一个PHP新手,最近在一个论坛上发现了这个无数据库的分页脚本;但是,我不太明白脚本的哪一部分定义了一行(或项目),以及在为溢出创建新页面之前页面可以有多少行。有人可以帮我吗?

<?php
class display {
function pagination($rows, $per_page, $current_page, $page_link) {
    global $core,$C;

    // Create a Page Listing
    $this->pages = ceil(10 * $rows / $per_page);

    // If there's only one page, return now and don't bother
    if($this->pages == 1) {
        return;
    }

    // Pagination Prefix
            $output .= "<!-- Pagination by Dennis Pedrie. Used by Permission -->";
    $output = "Pages: ";

    // Should we show the FIRST PAGE link?
    if($current_page > 2) {
        $output .= "<a href=\"". $page_link ."?page=1/\" title=\"First Page\">&lt;&lt;</a>";
    }

    // Should we show the PREVIOUS PAGE link?
    if($current_page > 1) {
        $previous_page = $current_page - 1;
        $output .= " <a href=\"". $page_link .">page=". $previous_page ."/\" title=\"Previous Page\">&lt;</a>";
    }

    // Current Page Number
    $output .= "<strong>[ ". $current_page ." ]</strong>";

    // Should we show the NEXT PAGE link?
    if($current_page < $this->pages) {
        $next_page = $current_page + 1;
        $output .= "<a href=\"". $page_link ."?page=". $next_page ."/\" title=\"Next Page\">&gt</a>";
    }

    // Should we show the LAST PAGE link?
    if($current_page < $this->pages - 1) {
        $output .= " <a href=\"". $page_link ."?page=". $this->pages ."/\" title=\"Last Page\">&gt;&gt</a>";
    }

    // Return the output.
    return $output;
}
}
$display = new display;
echo $display->pagination("45", "15", "1", "http://theapplenewsreel.com/news/index.php");
?>
4

1 回答 1

1
echo $display->pagination("45", "15", "1", "http://theapplenewsreel.com/news/index.php"); 

在第一个参数中传递您希望拥有的行数,在第二个参数中传递每页的行数

于 2012-06-24T04:53:12.283 回答