Here is a simple PHP connection to the MySQL database data paging display template. You can modify the information by annotation, the SQL statement inside can be changed.
Pay attention to the analysis and observation of the relevant pagination part of the code to write and implement the way.
<?php
$link = mysql_connect (' localhost ', ' root ', ') or Die (' MySQL database connect error ');
mysql_select_db (' your database ') or Die (' The selected database is not exist ');
?>
Insert your HTML code here,
<?php
$sql = ' SELECT count (*) count from your_table ';
$result = mysql_query ($sql) or Die (Mysql_errno (). ":". Mysql_error (). " \ n ");
$rs =mysql_fetch_object ($result);
$recountCount = $rs->count;
$show = 20;
$totalPage = Ceil ($recountCount/$show);
$page = (isset ($_get[' page ') && $_get[' page ']>=0)? $_get[' page ']: 0;
$isLast = ($page = = ($totalPage-1))? True:false;
$hasNoPre = ($page ==0)? True:false;
$hasNoNext = ($page = = $totalPage-1)? True:false;
$isFirst = ($page ==0)? True:false;
$start = $page * $show;
Mysql_free_result ($result);
?>
Insert your HTML code here,
?
$sql = "SELECT * from Your_table limit $start, $show";
$result = mysql_query ($sql) or Die (Mysql_errno (). ":". Mysql_error (). " \ n ");
while ($rs =mysql_fetch_object ($result)) {
The HTML code in this loop itself is more realistically modified
Echo $rs->art_id;
echo "<br>";
}
Mysql_free_result ($result);
?>
?
$str = "A total of $recountCount records, current section". ($page + 1). " /$totalPage page ";
$str. = $isFirst? "Home": "<a href=\"? page=0\ "> Home </a>";
$str. = $hasNoPre? "Previous page": "<a href=\"? page= ". ($page-1). " \ "> Prev </a>";
$str. = $hasNoNext? "Next page": "<a href=\"? page= ". ($page + 1). " \ "> next page </a>";
$str. = $isLast? "Last": "<a href=\"? page= ". ($totalPage-1). " \ "> Last </a>";
Echo $str;
?>