Do not pirate, reprint please add source Http://blog.csdn.net/yanlintao1
Do not pirate, reprint please add source Http://blog.csdn.net/yanlintao1
First, the style of the show hope to help everyone, but also hope that you give comments and suggestions:
The first type: Digital paging
Second: For the text of this page
PHP Paging function (I write in the common.inc.php common file introduced below):
/* *_page () Related parameters of pagination * @param int $_pagesize Each page has a few friends * @param $_sql get all fields */function _page ($_sql,$_size) {Global
$_pagenum,$_pagesize,$_pageabsolute,$_num,$_page;
Paging module and fault-tolerant processing//First page if (Isset ($_get[' page ')) {$_page = $_get[' page '];
if (Empty ($_page) $_page<0!is_numeric ($_page)) {$_page = 1;
}else{$_page = intval ($_page);
}}else{$_page = 1;
//Each page has several friends $_pagesize = $_size;
Get all data synthesized $_num = _num_rows (_query ($_sql));
Ceil see more than or equal to 1 to carry, calculate how many pages if ($_num = = 0) {$_pageabsolute = 1;
}else{$_pageabsolute = ceil ($_num/$_pagesize);
} if ($_page>$_pageabsolute) {$_page=$_pageabsolute;
///From the first few data of the database $_pagenum = ($_page-1) *$_pagesize; * * * _paging Paging function * @access Public representation function external * @param int $_type If 1 then by the number of pages, if 2 in text form page * $_pageabsolute Total number of pages * $_page Page * $_num How many pieces of data */function _paging ($_type) {Global $_PAGEABSOLute,$_page,$_num;
if ($_type==1) {echo '; Echo '
'; For ($i =0 $i <$_pageabsolute; $i + +) {if ($_page== ($i + 1)) {echo '
- '. ($i + 1). '
'; }else{Echo '
- '. ($i + 1). '
'; } Echo '
';
Echo ';
}elseif ($_type==2) {echo '; Echo '
'; Echo '
- '. $_page. ' /'. $_pageabsolute. ' Page
'; Echo '
- Total '. $_num. ' data
'; if ($_page==1) {echo '
- Home
'; Echo '
- Next page
'; Echo '
- Last
'; }elseif ($_page==$_pageabsolute) {echo '
- Home
'; Echo '
- Previous page
'; Echo '
- Last
'; }else{Echo '
- Home
'; Echo '
- Previous page
'; Echo '
- Next page
'; Echo '
- Last
'; } Echo '
';
Echo '; }
}
HTML code:
////introduction of Public documents require './includer/common.inc.php ';
Paging module, the first parameter gets the total number of bars, and the second argument obtains a few friends on each page global $_pagenum,$_pagesize;
_page ("Select tg_id from Tg_guest", 2); Data from the database, sorted by registration Time $_result = _query ("Select tg_username,tg_sex,tg_face,tg_id from Tg_guest orders by Tg_reg_time DESC LIMIT $_pagenum,$_pagesize ");?>
<title>Bo Friends</title>
--><script type= "Text/javascript" src= "Js/blog_message.js" ></script>
-->
Bo Friend Interface
-->
- ( )
-
"alt=" ">
-
"> Send a message
-
Add Friends
-
Write a message
-
Send Flowers
-->
-->
-->
Do not pirate, reprint please add source Http://blog.csdn.net/yanlintao1