Introduction: this is a typical PHP paging instance.CodeThe details page of PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 341663 'rolling = 'no'>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> PHP make page list </title>
<Style type = "text/CSS">
<! --
. Page A: link {
Color: # 0000ff;
Text-Decoration: none;
}
. Page A: visited {
Text-Decoration: none;
Color: # 0000ff;
}
. Page A: hover {
Text-Decoration: none;
Color: # 0000ff;
}
. Page A: active {
Text-Decoration: none;
Color: # 0000ff;
}
. Page {color: # 0000ff ;}
-->
</Style>
</Head>
<Body>
<Table width = "530" Height = "103" border = "0" align = "center" cellpadding = "0" cellspacing = "1" bgcolor = "# cccccc">
<Tr>
<TH width = "30" Height = "38" bgcolor = "# e3e3e3" Scope = "col"> id </Th>
<TH width = "500" bgcolor = "# e3e3e3" Scope = "col"> Article Title </Th>
</Tr>
<? PHP
/*
* Created on 2010-4-17
*
* Order by kove Wong
*/
$ Link = mysql_connect ('localhost', 'root', 'haoxiazai1987 ');
Mysql_select_db ('pagelist ');
Mysql_query ('set names gbk ');
$ Page_size = 10;
$ Result = mysql_query ('select * From v_char ');
$ COUNT = mysql_num_rows ($ result );
$ Page_count = Ceil ($ count/$ page_size );
$ Init = 1;
$ Page_len = 7;
$ Max_p = $ page_count;
$ Pages = $ page_count;
// Determine the current page number
If (empty ($ _ Get ['page']) | $ _ Get ['page'] <0 ){
$ Page = 1;
} Else {
$ Page = $ _ Get ['page'];
}
$ Offset = $ page_size * ($ page-1 );
$ SQL = "select * From v_char limit $ offset, $ page_size ";
$ Result = mysql_query ($ SQL, $ link );
While ($ ROW = mysql_fetch_array ($ result )){
?>
<Tr>
<TD bgcolor = "# e0eee0" Height = "25px"> <Div align = "center">
<? PHP echo $ row ['id']?>
</Div> </TD>
<TD bgcolor = "# e0eee"> <Div align = "center">
<? PHP echo $ row ['name']?>
</Div> </TD>
</Tr>
<? PHP
}
$ Page_len = ($ page_len % 2 )? $ Page_len: $ pagelen + 1; // number of page numbers
$ Pageoffset = ($ page_len-1)/2; // page number offset between left and right
$ Key = '<Div class = "page"> ';
$ Key. = "<span> $ page/$ pages </span> & nbsp;"; // page
If ($ page! = 1 ){
$ Key. = "<a href = \" ". $ _ server ['php _ Self ']."? Page = 1 \ "> page 1 </a>"; // page 1
$ Key. = "<a href = \" ". $ _ server ['php _ Self ']."? Page = ". ($ page-1)." \ "> previous page </a>"; // Previous Page
} Else {
$ Key. = "first page"; // first page
$ Key. = "Previous Page"; // Previous Page
}
If ($ pages> $ page_len ){
// If the current page is less than or equal to the left offset
If ($ page <= $ pageoffset ){
$ Init = 1;
$ Max_p = $ page_len;
} Else {// if the current page is greater than the left offset
// If the right offset of the current page number exceeds the maximum page number
If ($ page + $ pageoffset >=$ pages + 1 ){
$ Init = $ pages-$ page_len + 1;
} Else {
// Calculation when both the left and right offsets exist
$ Init = $ page-$ pageoffset;
$ Max_p = $ page + $ pageoffset;
}
}
}
For ($ I = $ Init; $ I <= $ max_p; $ I ++ ){
If ($ I = $ page ){
$ Key. = '<span>'. $ I. '</span> ';
} Else {
$ Key. = "<a href = \" ". $ _ server ['php _ Self ']."? Page = ". $ I." \ ">". $ I. "</a> ";
}
}
If ($ page! = $ Pages ){
$ Key. = "<a href = \" ". $ _ server ['php _ Self ']."? Page = ". ($ page + 1)." \ "> next page </a>"; // next page
$ Key. = "<a href = \" ". $ _ server ['php _ Self ']."? Page = {$ pages} \ "> last page </a>"; // last page
} Else {
$ Key. = "next page"; // next page
$ Key. = "last page"; // last page
}
$ Key. = '</div> ';
?>
<Tr>
<TD colspan = "2" bgcolor = "# e0eee0"> <Div align = "center"> <? PHP echo $ key?> </Div> </TD>
</Tr>
</Table>
</Body>
</Html> |
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/341663.html pageno: 6.