Paging display is one of the most frequently processed links in WEB programming. The paging display is to display the result set in a segment by a program. Two initial parameters are required for Pagination: the number of records displayed on each page and the current number of pages. With the complete result set added, you can achieve data paging.
Paging display is one of the most frequently processed links in WEB programming. The paging display is to display the result set in a segment by a program. Two initial parameters are required for Pagination: the number of records displayed on each page and the current number of pages. With the complete result set added, the data can be displayed by page. Other functions, such as the previous and next pages, can be processed based on the above information.
To obtain the first 10 records in a table, use the following SQL statement:
SELECT * FROM a_table LIMIT 0,10
To query 11th to 20th records, use the following SQL statement:
SELECT * FROM a_table LIMIT 10,10
To search for 21st to 30th records, use the following SQL statement:
SELECT * FROM a_table LIMIT 20,10
The preceding SQL statement shows that 10 records are Retrieved each time, which is equivalent to 10 data records displayed on each page. The relationship between the start position of each log and the current page number is as follows: start position = (current page-1) * number of records to be displayed on each page. If the variable $ page_size represents the number of records displayed on each page and the variable $ cur_page represents the current page number, the preceding statements can be summarized using the following SQL statement template:
select * from table limit ($cur_page-1)*$page_size,$page_size;
In this way, the SQL statement for retrieving data by page is obtained. $ Page_size can be set as a value based on actual conditions. in actual development, the current page $ cur_page can be passed in by parameters. In addition, the total number of pages to be displayed can be calculated between the total number of records and the number of records displayed on each page. For example, if there is no remainder after the total number of records is divided by the number of records displayed on each page, the total number of pages is the quotient of the two.
ERROR:". Mysql_error ()."
SQL: ". $ SQL);?>13-8.php
Post get is a form submission method. GET is obtained with $ _ GET and $ _ POST is used for form submission.
The difference between post and get is that one parameter is displayed in the address bar and the other parameter is not displayed.
For example, if you use the get method when logging on, your value will be displayed in the address bar, so there is no security.
You can use post to hide the parameter in the address bar when searching for or having a page number. This makes no sense.
You can use $ _ GET to obtain the parameter values in the browser address bar (? A string after the question mark), such as www.baidu.com/s? Wd = 123, then you can use $ _ GET to obtain the parameter (you can think of it as an event, action, or parameter. this value is consistent with the input name when passing the form) it is the wd value of 123, and multiple parameters are connected with the & operator, for example? An = 0 & si = 5 is interpreted as an parameter value 0 and si parameter value 5.
**********************
For example, you enter an address called www.iron-feet.cn /? Page = 2
$ _ GET ["page"] is to GET the value of this page on the address, that is, GET 2
| ID |
Name |
Sex |
Age |
| |
|
|
|
**********************