Home  >  Article  >  Backend Development  >  Solve the problem when thinkphp uses paginate to paginate

Solve the problem when thinkphp uses paginate to paginate

little bottle
little bottleforward
2019-04-22 15:53:194789browse

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()]);

'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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete