<?
$ Limit = 25;
If (! Empty ($ start) $ start = 0;
If (! Empty ($ s) $ s = 0;
Mysql_connect ("localhost ","","");
Mysql_select_db (database );
// Count the total number of database records
$ Result = mysql_query ("select * from table ");
$ Num = mysql_numrows ($ result );
$ Result = mysql_query ("select * from table order by id limit $ start, $ limit ");
$ Numb = mysql_numrows ($ result );
Echo "<table> ";
If (! Empty ($ numb )){
For ($ I = 0; $ I <$ numb; $ I ++ ){
$ Val = mysql_result ($ result, $ I, "val ");
$ Val1 = mysql_result ($ result, $ I, "val1 ");
Echo "<tr> <td> $ val </td> <td> $ val1 </td> </tr> ";
}
}
Echo "</table> ";
// Control of digital loop page turning
Echo "<table> ";
Echo "<tr> <td> page: </td> ";
// Forward flip Control
If ($ s> 20 ){
If ($ s = 21 ){
$ St = $ S-21;
} Else {
$ St = $ S-20;
}
$ Pstart = $ st * $ limit;
Echo "<td> <a href = page. php? ";
Echo "start = $ pstart & s = $ st> prve </a> </td> ";
}
Echo "<td >></td> ";
// Set no link to the page number of the current page
$ Star = $ start;
// Pay attention to the initial value of the loop. Think carefully about why it is not 0.
For ($ page = $ s; $ page <($ num/$ limit); $ page ++ ){
$ Start = $ page * $ limit;
Echo "<td> ";
If ($ page! = $ Star/$ limit ){
Echo "<a href = page. php? ";
Echo "start = $ start & s = $ s> ";
}
Echo $ page;
If ($ page! = $ Star/$ limit ){
Echo "</a> ";
}
Echo "</td> ";
// Control the restricted display function of the number page. Only 20 pages are displayed.
If ($ page> 0 & ($ page % 20) = 0 ){
If ($ s = 0 ){
$ S = $ s + 21;
} Else {
$ S = $ s + 20;
}
$ Start = $ start + $ limit;
If ($ num/$ limit)-1)> $ page ){
Echo "<td> </td> <a href 'page. php? ";
Echo "start = $ start & s = $ s> next </a> </td> ";
}
// Note the loop jump Control
Break;
}
}
Echo "</tr> </table> ";
?>
The preceding steps are sorted to provide powerful cyclic page turning functions.