PHP简单分页的实现
程序员文章站
2022-06-17 15:11:01
...
程序的关键点是页码的获取 "; // echo "
"; echo "
"; $url=$_SERVER["PHP_SELF"]; $pageNow =isset($_GET['pageNow'])?$_GET['pageNow']:1; $start=($pageNow-1)*$every; $allsql = "select * from {$table};"; // die(); // $sql = "select * from test;"; $rest = $conn->query($allsql); $field = $rest->fetch_fields(); $fieldNum = count($field); //字段数量 //获取数据量 $rowNum = $rest->num_rows; // echo "记录条数:".$rowNum; $allpage=ceil($rowNum/$every); // echo "----每页分$every"."条时有$allpage"."页
"; // $pageNow=($pageNow-1)*$every; echo "
"; echo ""; echo "
";$conn->close();}//实际使用一个测试数据表echo pagef(10,'test');?> //css文件
*{padding: 0px; margin: 0px;}.center{text-align: left; color: red; text-indent: 500px;}#info{color: DodgerBlue;}.table{ margin-left: auto; margin-right: auto; width: auto; text-align: center; color: royalblue; border: 0; }.td{width: 150px; /*text-indent: 10px;*/ text-align: left; font-size: 14px;}#td{color: #555;}tr:hover{background-color: DodgerBlue;}.info{text-align: center; color: red;}.link{color: blue; text-decoration: none; text-align: center; font-size: 12px;}.h3{text-align: center; }#divclass{width: 100%; height: 30px; margin-top: 10px; font-size: 18px; /*background: coral;*/ }#center{width: 27%; /*display: inline-block;*/ height: 30px; margin-left: auto; margin-right: auto; /*background: orange;*/ }.fy{ /*background: DodgerBlue;*/ height: 30px; line-height: 30px; display: inline-block; float: left; color: DodgerBlue; padding-left: 5px; text-decoration: none; text-align: center; }.option{width: 80px; height: 30px; background: white; float: left; border: 2px solid DodgerBlue; display: inline-block;}.button{width: 56px; float: left; color: white; background: DodgerBlue; height: 30px; border: 0px; border-radius: 0px; display: inline-block;}
上一篇: 怎么解析https协议的域名?
下一篇: 这个界面如何做