【问题标题】:how to fix pagination continuous number of page IN PHP如何在PHP中修复分页连续页数
【发布时间】:2017-07-27 19:47:09
【问题描述】:

这是我的 index.php 代码 我的问题是我的分页有连续的数字 页。

<?php
    $limit = 10;
    $offset = (isset($_GET["page"]) ? $_GET["page"] - 1 : 0) * $limit;
    $query = "SELECT * FROM employee ORDER BY employee_datecommenced ASC LIMIT                    
    $offset,$limit ";
    $list = getdata_inner_join($query);
?>

<?php
    $total = $dbcon->query("SELECT count(*) FROM employee") or
    die(mysqli_error());     
    $fetch = $total->fetch_assoc();
    for($x = 0; $x < $fetch["count(*)"] / $limit ; $x ++){
        $page = $x + 1;
        if((isset($_GET["page"]) ? $_GET["page"] : 1) == $page)
        $page = "<b>".$page."</b>";  
        echo '<a href="?page='.($x + 1).'"style="padding:2px;">'.$page.'</a>&nbsp;';
    }
?>

Click here to see the output photo

提前致谢

【问题讨论】:

标签: php mysqli pagination


【解决方案1】:

您说“我的问题是我的分页有连续的页数”,但为什么会出现问题?你需要改变什么?

【讨论】:

  • 我需要像这样限制数量Prev 1 2 3 4 5 6 .. 40 41 Next
  • 你为什么要问答案?
  • '因为系统不让我发表评论:(
【解决方案2】:

在你的for循环中打印锚标签,检查当前页面,如果假设页面是($current),禁用($current-1),打印$current到($current+5)和'. ...' 和 (current+1),如果 current 是 $min 或 $max 管理上一个和下一个

【讨论】:

    猜你喜欢
    • 2013-04-07
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多