-----------------pagetpl.php----------------------
1
2$link = mysql_connect('localhost', 'root', '') or die('mysql database connect error');
3mysql_select_db('your database') or die('the selected database is not exist');
//这里插入你的html代码,
1
2$sql = 'select count(*) count from your_table';
3$result = mysql_query($sql) or die(mysql_errno().": ".mysql_error()."\n");
4$rs=mysql_fetch_object($result);
5$recountCount = $rs->count;
6$show = 20;
7$totalPage = ceil($recountCount/$show);
8$page = (isset($_GET['page']) && $_GET['page']>=0)? $_GET['page']: 0;
9$isLast = ($page==($totalPage-1))? true: false;
10$hasNoPre = ($page==0)? true: false;
11$hasNoNext = ($page==$totalPage-1)? true: false;
12$isFirst = ($page==0)? true:false;
13$start = $page*$show;
14mysql_free_result($result);
//这里插入你的html代码,
art_id; echo " `````` "; } mysql_free_result($result); ?> 首页 "; $str .= $hasNoPre? "上一页 " : " ``` 上一页 ``` "; $str .= $hasNoNext? "下一页 " : " ``` 下一页 ``` "; $str .= $isLast? "尾页 " : " ``` 尾页 ``` "; echo $str; ?>