Qeephp content paging

Source: Internet
Author: User
When there are many items in the list, we can display the data by page. The structure of the user table is now displayed as a list. Obviously, it is impossible to display the query results on a single page. in this case, you must display the results by page. copy php to project... syntaxHighlighter. all ();

When there are many items in the list, we can display the data by page.

Structure of the user table

 

Now we want to display the user in the form of a list. Obviously, it is impossible to display the query results on one page. in this case, we need to display the results by page. First, we need to control the page by page. copy php to the control file of the project, and then enter the following code in the controller:

01
Function actionCusList ()
02
{
03
$ Cus_info = User: find ();
04
// Obtain the current page
05
$ Page = intval ($ this-> _ context-> page );
06
$ Page <1? 1: $ page;
07
// Set the number of entries displayed on each page
08
$ Page_size = 10;
09

10
// Search for users based on conditions
11
If ($ id = $ this-> _ context-> get ('cuz _ id '))
12
$ Cus_info-> where ('Id =? ', $ Id );
13
Else
14
{
15
If ($ first_name = $ this-> _ context-> get ('First _ name '))
16
$ Cus_info-> where ('First _ name =? ', $ First_name );
17

18
If ($ last_name = $ this-> _ context-> get ('last _ name '))
19
$ Cus_info-> where ('last _ name =? ', $ Last_name );
20

21
If ($ email = $ this-> _ context-> get ('email '))
22
$ Cus_info-> where ('email =? ', $ Email );
23

24
If ($ code = $ this-> _ context-> get ('code '))
25
$ Cus_info-> where ('Pro _ id =? ', Program: find ('code =? ', $ Code)-> getOne ()-> id );
26
}
27

28
$ Cus_info-> limitPage ($ page, $ page_size );
29
$ Cus = $ cus_info-> getAll ();
30

31
// Rendering view
32
$ This-> _ view ['url _ args '] = $ this-> _ context-> get ();
33
$ This-> _ view ['pagination'] = $ cus_info-> getPagination ();
34
$ This-> _ view ['scs'] = $ SCUs;
35
}
One of the items in this code is to search for users by conditions. we can design a form on the foreground to allow users to enter specific conditions to search for users. the code is as follows:

01

02
"> Search>
03

04

05

06

07
Close
08

34

35

36

37
_ Control ('page', 'P', array ('pagination' => $ pagination, 'URL _ args '=> $ url_args);?>
38

39



















































40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 63 64 65 66
Cust. IDFirst NameLast NameEmail AddressProgramLast LoginAction

61
$ Cus ['id'])?> "Title =" View "> View
62

67

68
_ Control ('page', 'P', array ('pagination' => $ pagination, 'URL _ args '=> $ url_args);?>
69

The key code for paging is:

1
_ Control ('page', 'P', array ('pagination' => $ pagination, 'URL _ args '=> $ url_args);?>
Display result

 


Author: frylan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.