使用像Indeed.com这样的PHP进行分页

时间:2009-09-26 06:27:18

标签: php paging

任何人都帮助我如何使用php这样的分页进行分页。

注意: 1.页面视图是:1,2,3,4,.... 但是?start = 10,?start = 20,...

2 个答案:

答案 0 :(得分:2)

原则如下:

$total = 40;  // total item count
$itemsPerPage = 10;
$pages = ceil($total / $itemsPerPage);

echo '<ul>';
for ($i = 0; $i < $pages; ++$i) {
    echo '<li><a href="?start=' . ($i * $itemsPerPage) . '">' . ($i + 1) . '</a></li>';
}
echo '</ul>';

答案 1 :(得分:0)

关于如何在PHP和MySQL中执行此操作的体面文章 http://www.php-mysql-tutorial.com/wikis/php-tutorial/paging-using-php.aspx