Solve the problem when thinkphp uses paginate to paginate

little bottle
Release: 2023-04-06 08:42:01
forward
4794 people have browsed it

This article is about the solution to the problem that when thinkphp uses paginate to paginate and click the next page, the search conditions disappear. Friends who have the same problem can learn about it.

Some netizens said that when they used paginate for paging in a project recently, they found that when searching, the search conditions disappeared when you clicked on the next page, so they searched for some methods on the Internet. Some said they used the Page class, but I am used to using paginate, but I am not used to using Page. I found a way to use paginate to search for pagination.

->paginate(15,false,['query'=>request()->param()]);
Copy after login

'query'=>request()->param() is to get the parameters carried, but just writing it like this is not enough, because when the mouse is placed on the pagination page number, it is found that the search condition has always existed Yes, but the data is wrong, because the page number link here uses the get method to pass parameters, so when receiving parameters, you need to use the get method to receive parameters. If some people's search conditions are to use post, it doesn't matter, you can use input('param.') Receiving, because param receives get and post parameters, all using this reception can carry out paging and receive search conditions, so that the paging data is also correct.

Related tutorials: PHP video tutorial

The above is the detailed content of Solve the problem when thinkphp uses paginate to paginate. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!