PHP通用分页
程序员文章站
2022-04-25 23:24:35
...
php通用分页,先看下样式
代码如下:
0 ? intval($page) : 1;$conn = mysql_connect("127.0.0.1","root","") or die('连接数据库失败');mysql_select_db("demo",$conn);mysql_query("SET NAMES UTF8");$pageSize = 10;//每页显示的数据$showPage = 5;//显示页码$sql = "select * from demo limit ".($page-1)*$pageSize.",".$pageSize;$result = mysql_query($sql,$conn);echo '';mysql_free_result($result);$total_sql = "select count(*) from demo";$total_result = mysql_fetch_array(mysql_query($total_sql));$total = $total_result[0];//计算总页数$total_page = ceil($total/$pageSize);mysql_close($conn);/*分页条*/$page_banner = '';echo $page_banner;';echo '
';while($row = mysql_fetch_assoc($result)){ echo ' ID NAME '; echo ' ';}echo ''.$row['id'].' '; echo ''.$row['name'].' '; echo '
下一篇: PHP微信开发之有道翻译,php有道