My pages, but there is an error. Please check if this is my page. But there is an error. for example, if I click the last page and then the previous page, she is still on this page. this is also the case after I click the next page on the homepage. ask for advice! $ SQL = & quot; select * frompl_transaction_sun & quot; $ query = mysql_quer
This is the page I wrote. But there is an error. for example, if I click the last page and then the previous page, she is still on this page. this is also the case after I click the next page on the homepage. ask for advice!
$ SQL = "select * from pl_transaction_sun ";
$ Query = mysql_query ($ SQL );
$ Num = mysql_num_rows ($ query );
$ Pagesize = 3;
$ Start = $ _ GET ['start'];
$ Flag = $ _ GET ['flag'];
// Determine whether $ start has a value
If ($ start = null ){
$ Start = 0;
}
// Determine whether $ flag has a value
If ($ flag = null ){
$ Flag = 0;
}
$ Sql1 = "select * from pl_transaction_sun limit $ start, $ pagesize ";
$ Query1 = mysql_query ($ sql1 );
// $ Num1 = mysql_num_rows ($ query1 );
// Determine the flag bit to determine the value of $ start
If ($ flag = 1 and $ start + $ pagesize <$ num ){
$ Start = $ start + $ pagesize;
}
If ($ flag = 2 and $ start + $ pagesize> 0 ){
$ Start = $ start-$ pagesize;
}
// Start id on the last page
If ($ num % $ pagesize )! = 0 ){
$ Lastpage = $ num-($ num % $ pagesize );
} Else {
$ Lastpage = $ num-$ pagesize;
}
// Determine the page number and current page code
$ Pagenum = ceil ($ num/$ pagesize );
If ($ start = 0 ){
$ Nowpage = 1;
} Else {
$ Nowpage = ($ start/$ pagesize) + 1;
}
Print (" ");
// Display the judgment part by page
If ($ start = 0 and $ pagesize <$ num ){
Print ("[Homepage] [previous page]
[Next Page]
[Last Page ]");
} Elseif ($ start >=$ num-$ pagesize and $ pagesize <$ num ){
Print ("
[Homepage]
[Previous page]
[Next Page] [last page ]");
} Elseif ($ pagesize >=$ num ){
Print ("[Homepage] [Previous Page] [Next Page] [last page ]");
} Else {
Print ("
[Homepage]
[Previous page]
[Next Page]
[Last Page ]");
}
------ Solution --------------------
$ Query1 = mysql_query ($ sql1 );
It should be executed after the new $ start is generated
The control logic is too complex. you only need to pass the desired page number. It is recommended to adjust it.
------ Solution --------------------
For a beginner, Shenma is a cloud ......
------ Solution --------------------
Paging is actually very simple. determine how many entries are displayed on a page and then calculate the number of all entries.
------ Solution --------------------
Pagination is a small gap that must be crossed by web programs. It is worthwhile to spend some time.
Because there are too many places to use, you need to encapsulate it into a function or a method in the class.
PHP code
$ Page = isset ($ _ GET ['Page'])? Intval ($ _ GET ['Page']): 1; $ perNum = 10; $ offset = max ($ page-1) * $ perNum), 0 ); // SQL $ vpage = page ($ total, $ page, $ perNum, $ url );