如何在PHP中实现分页?

时间:2020-12-08 14:31:30

How are paged results commonly implemented in PHP?

页面搜索结果是如何在PHP中实现的?

I'd like to have a results page with 10 results. Paging forward in the navigation would give me the next and previous sets.

我想要一个有10个结果的结果页面。导航中的分页forward将给出下一个和上一个集合。

Is there a way this is commonly done? Does anyone have simple advice on getting started?

是否有一种常见的方法?有人对入门有什么简单的建议吗?

7 个解决方案

#1


7  

You'll need a beginner's understanding of PHP, and probably some understanding of relational databases.

您需要对PHP有一个初步的了解,可能还需要对关系数据库有一些了解。

Pagination is often implemented with some simple query parameters.

分页通常使用一些简单的查询参数实现。

*.com/myResults.php?page=1

The page increments the query parameter:

页面递增查询参数:

*.com/myResults.php?page=2

On the back end, the page value usually corresponds to the limits and offsets in the query that is being used to generate the results.

在后端,页面值通常对应于用于生成结果的查询中的限制和偏移量。

Related Questions:

相关问题:

#2


0  

The term you are referring to is "pagination". Unfortunately you'll have to give some more information to get a more specific answer.

你所指的是“分页”。不幸的是,你必须提供更多的信息才能得到更具体的答案。

#3


0  

What you are looking for is called pagination. There have been several questions on SO about this subject. As your question is very broad, please provide more details or refer to the questions that have already been asked about this subject.

您正在寻找的是分页。关于这个问题,有几个问题。由于你的问题非常广泛,请提供更多的细节或参考已经被问到的问题。

#4


0  

It may be worth looking at the Zend Framework's Zend_Paginator object. It encapsulates a lot of the logic of generating next/previous/first/last type links.

可能值得查看Zend框架的Zend_Paginator对象。它封装了生成next/previous/first/last类型链接的许多逻辑。

#5


0  

The TinyButStrong template system comes with a pagination extension. Very easy to use.

TinyButStrong模板系统附带了分页扩展。非常容易使用。

#6


0  

For server-side paging, I use PEAR's Pager package (http://pear.php.net/package/Pager).

对于服务器端分页,我使用PEAR的寻呼机包(http://pear.php.net/package/Pager)。

Take a look at example.php for basic usage, and Page_Wrapper.php (I started with Pager_Wrapper_DB).

举个例子。php用于基本用法,Page_Wrapper。php(我从Pager_Wrapper_DB开始)。

The end-user docs are quite comprehensive: http://pear.php.net/manual/en/package.html.pager.intro.php

最终用户文档非常全面:http://pear.php.net/manual/en/package.html.pager.intro.php

#7


-1  

If database is not so big - I implement pagination on client side. I recommend jquery plugin tablefilter - it gives you not only pagination, but also filtering and sorting. You can easily browse through given recordset. It's very good solution if performance is not very important. There's page: http://ideamill.synaptrixgroup. and demo for 830 records: http://ideamill.synaptrixgroup.com/jquery/tablefilter/largetabletest.htm

如果数据库不是很大,我在客户端实现分页。我推荐jquery插件tablefilter——它不仅给你分页,而且还可以过滤和排序。您可以轻松浏览给定的记录集。如果性能不是很重要,这是一个很好的解决方案。有页面:http://ideamill.synaptrixgroup。并且演示了830条记录:http://ideamill.synaptrixgroup.com/jquery/tablefilter/largetabletest.htm。

#1


7  

You'll need a beginner's understanding of PHP, and probably some understanding of relational databases.

您需要对PHP有一个初步的了解,可能还需要对关系数据库有一些了解。

Pagination is often implemented with some simple query parameters.

分页通常使用一些简单的查询参数实现。

*.com/myResults.php?page=1

The page increments the query parameter:

页面递增查询参数:

*.com/myResults.php?page=2

On the back end, the page value usually corresponds to the limits and offsets in the query that is being used to generate the results.

在后端,页面值通常对应于用于生成结果的查询中的限制和偏移量。

Related Questions:

相关问题:

#2


0  

The term you are referring to is "pagination". Unfortunately you'll have to give some more information to get a more specific answer.

你所指的是“分页”。不幸的是,你必须提供更多的信息才能得到更具体的答案。

#3


0  

What you are looking for is called pagination. There have been several questions on SO about this subject. As your question is very broad, please provide more details or refer to the questions that have already been asked about this subject.

您正在寻找的是分页。关于这个问题,有几个问题。由于你的问题非常广泛,请提供更多的细节或参考已经被问到的问题。

#4


0  

It may be worth looking at the Zend Framework's Zend_Paginator object. It encapsulates a lot of the logic of generating next/previous/first/last type links.

可能值得查看Zend框架的Zend_Paginator对象。它封装了生成next/previous/first/last类型链接的许多逻辑。

#5


0  

The TinyButStrong template system comes with a pagination extension. Very easy to use.

TinyButStrong模板系统附带了分页扩展。非常容易使用。

#6


0  

For server-side paging, I use PEAR's Pager package (http://pear.php.net/package/Pager).

对于服务器端分页,我使用PEAR的寻呼机包(http://pear.php.net/package/Pager)。

Take a look at example.php for basic usage, and Page_Wrapper.php (I started with Pager_Wrapper_DB).

举个例子。php用于基本用法,Page_Wrapper。php(我从Pager_Wrapper_DB开始)。

The end-user docs are quite comprehensive: http://pear.php.net/manual/en/package.html.pager.intro.php

最终用户文档非常全面:http://pear.php.net/manual/en/package.html.pager.intro.php

#7


-1  

If database is not so big - I implement pagination on client side. I recommend jquery plugin tablefilter - it gives you not only pagination, but also filtering and sorting. You can easily browse through given recordset. It's very good solution if performance is not very important. There's page: http://ideamill.synaptrixgroup. and demo for 830 records: http://ideamill.synaptrixgroup.com/jquery/tablefilter/largetabletest.htm

如果数据库不是很大,我在客户端实现分页。我推荐jquery插件tablefilter——它不仅给你分页,而且还可以过滤和排序。您可以轻松浏览给定的记录集。如果性能不是很重要,这是一个很好的解决方案。有页面:http://ideamill.synaptrixgroup。并且演示了830条记录:http://ideamill.synaptrixgroup.com/jquery/tablefilter/largetabletest.htm。