无法弄清楚这个PHP脚本

时间:2012-06-24 04:47:27

标签: php database pagination row

我是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");
?>

1 个答案:

答案 0 :(得分:1)

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

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