Simple use of PHP thanks to a paging function module, PHP paging function module
Put a picture first to see the effect.
Just post the code.
Php$localhost= "localhost"; $username= "Root"; $password= "Root"; $db= "Test";//Information $pagesize= 5; $conn=mysql_connect($localhost,$username,$password);//Link Database if(!$conn){ Echo"Database link failed."Mysql_error(); } mysql_query("SET NAMES ' UTF8 '");//Code Conversion $db _select=mysql_select_db($db);//Select Table//Total number of query records $total _sql= "Select COUNT (*) from page"; $total _result=mysql_query($total _sql); $total _row_arr=Mysql_fetch_row($total _result); $total _row=$total _row_arr[0];//Total number of articles//total pages $total=Ceil($total _row/$pagesize); //Current Page $page= @$_get[' P ']?$_get[' P ']: 1; //Limit Limit $offset= ($page-1) *$pagesize; $sql= "SELECT *" from page order by ID limit {$offset},{$pagesize}"; $result=mysql_query($sql); Echo"PHP pagination code for small modules
"; Echo"; Echo; while$rowMysql_fetch_assoc$result)){ $id$row]; $name$row]; Echo; } Echo
" "
Id |
NAME |
(= (= [' id ' = [' name ']
". $id. " |
". $name. " |
" "
"; //previous page, next page $pageprev=$page-1 ; if($page>$total){ $pagenext=$total; } Else{ $pagenext=$page+1; } //do link jump; Echo"
$pageprev} ' > previous page 丨 $pagenext} ' > Next
"; Mysql_free_result($result); Mysql_close($conn);?>
Key points: 1,$sql = "SELECT * from page order by ID limit {$offset},{$pagesize}";
2,echo "
$pageprev} ' > previous page 丨 $pagenext} ' > Next
" ;
These two points are the key to the art of paging technology and PHP code-
Learn with US ~
http://www.bkjia.com/PHPjc/1015277.html www.bkjia.com true http://www.bkjia.com/PHPjc/1015277.html techarticle simple use of PHP thanks to a paging function module, PHP paging function module First paste a picture to see the effect of the code bar? php $localhost = "localhost"; $username = "root"; $pa ...