<? Php
Require '../inc/conn. php ';
?>
<? Php
// Initial parameter settings
$ Pagesize = 5; // page size
$ Pagenum = 1; // the first page is displayed by default.
// Step 1: Obtain the current page
If ($ _ GET ){
If ($ _ GET ['pagenum']) {
$ Pagenum = $ _ GET ['pagenum'];
}
}
// Step 2: Obtain the content list of the current page
$ SQL = "Select * From message limit". ($ pagenum-1) * $ pagesize. ", $ pagesize ";
$ Result = mysql_query ($ SQL );
While ($ row = mysql_fetch_array ($ result) = true ){
Echo '}
// Step 3: obtain the number of records
$ SQL = "Select id From message ";
$ Result = mysql_query ($ SQL );
$ Rownum = mysql_num_rows ($ result );
// Step 4: count the number of minutes
If ($ rownum % $ pagesize) = 0 ){
$ Pagecount = $ rownum/$ pagesize;
} Else {
$ Pagecount = (int) ($ rownum/$ pagesize );
}
// Step 5: Get the paging Link
$ Url = $ _ SERVER ["REQUEST_URI"];
$ Url = parse_url ($ url );
$ Url = $ url ["path"];
// Step 6: output the paging Link
If ($ pagenum = 1 ){
Echo "[first page] [Previous Page]";
} Else {
Echo "[<a href = \" $ url? Pagenum = 1 \ "> page 1 </a>] [<a href = \" $ url? Pagenum = ". ($ pagenum-1)." \ "> previous </a>]";
}
If ($ pagecount = $ pagenum ){
Echo "[Next Page] [last page]";
} Else {
Echo "[<a href = \" $ url? Pagenum = ". ($ pagenum + 1)." \ "> next page </a>] [<a href = \" $ url? Pagenum = ". ($ pagecount)." \ "> last page </a>]";
}
?>