①. The most basic SQL statement
SELECTFROM 表名 LIMIT 开始位置,显示条数
②. The simplest page-paging logic
1. Incoming page numbers
$page$_GET[‘p‘];
2. Incoming data based on page numbers
$host="localhost";$username="Root";$password="";$db="Test";//Connect database$conn= Mysql_connect ($host,$username,$password);if(!$conn){Echo "Database connection Failed";Exit;} Select the database that you want to manipulate mysql_select_db ($db);//Set the database encoding format mysql_query ("SET NAMES UTF8")//write SQL to get paging data$sql="SELECT * from page LIMIT". ($page-1) *Ten.", ten";//Transfer SQL statements to the database$result= mysql_query ($sql);//processing of our dataEcho ' <table border = 1 cellspacing = 0 width = 40%> 'Echo "<tr><td>ID</td><td>NAME</td></tr>" while($row= MYSQL_FETCH_ASSOC (Result)) {Echo "<tr>";Echo "<td>{$row[' id ']}</td> ' Echo "<td>{$row[' name ']}</td> ' Echo "</tr>"; //Echo $row[' id '] .'-'.$row[' name '] .' <br> ';}Echo "</table>"Release the results, close the link mysql_free_result ($result); Mysql_close ($conn);
3. Display Data + pagination bar
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Learning from Mu-php+mysql--the realization of the principle of pagination