• PHP 简单实现文章内容自动分页


    $sql1 = "select count(*) from daohang where aid={$id}";
    $result1 = MYSQLi_query($conn,$sql1);
    $page = mysqli_fetch_row($result1);// 信息总数
    $page = $page[0];
    $pagesize=4;// 每页显示数量
    $num = ceil($page/$pagesize);
    $pagenum = empty($_GET["pagenum"])?1:$_GET["pagenum"];// 第几页
    
        $sql = "select a.id,a.url,a.title from daohang as a where aid ={$id} limit ".($pagenum-1)*$pagesize.",".$pagesize;
        $result =mysqli_query($conn,$sql);
        if($result){
            while ($row = mysqli_fetch_assoc($result)) {
                echo "<div class='nav-1 col-md-5'>";
                echo "<a class='link' target='_blank' href=".$row['url'].">".$row['title']."
                </a></div>";
            }
        }
        echo "<div style="clear:both;"></div><div class="pagess"><ul class="pagination">";
    echo "<li><a href='?pagenum=1'>首页</a></li>";
    for($i=1;$i<$num+1;$i++){
        echo "<li><a href='?pagenum=".$i."'>第".$i."页</a></li>";
    }
    echo "<li><a href='?pagenum=".$num."'>末页</a></li>";
    echo "<li><a>共".$num."页</a></li>";
    echo "</ul></div>";
    

     来源:http://www.cuteur.cn/post/647.html

  • 相关阅读:
    sql-定义变量
    sql-逻辑循环while if
    iOS生命周期
    iOS系统架构
    SVN记住密码
    视图在控制权限的作用
    20140524数据库课笔记
    char和varchar区别
    多表查找
    create table约束
  • 原文地址:https://www.cnblogs.com/cuteur/p/13692558.html
Copyright © 2020-2023  润新知