php分页代码简单实现_PHP教程
程序员文章站
2022-05-25 15:59:08
...
php分页代码简单实现
数据库操作类代码:mysqli.func.php
num_rows; } // 关闭数据库 function closedb() { if (! mysqli_close()) { exit('关闭异常'); } } ?>
分页实现代码:
$pagenum) echo ""; //计算分页起始值 if ($tmp == "") { $num = 0; } else { $num = ($tmp - 1) * $fnum; } // 查询语句 $sql = "SELECT dg_id,dg_username FROM tb_user ORDER BY dg_id DESC LIMIT " . $num . ",$fnum"; $result = doresult($sql); // 遍历输出 while (! ! $rows = dolists($result)) { echo $rows['dg_id'] . " " . $rows['dg_username'] . "
"; } // 翻页链接 for ($i = 0; $i
简单实现了翻页功能,数据库请自行配置结构