PHP分页:不会在下一页显示

时间:2018-01-29 09:26:13

标签: php jquery pagination

美好的一天!我的分页有问题,我的分页会显示从日期(2018年1月1日)到日期(2018年1月31日)之间的数据,在第一页它正常工作。当我点击下一页时结果消失了,我必须在日期之间重新输入数据。这是我的分页代码。

<div id="divWrapper">
    <button content="test content" class="btn">test value</button>
</div>

我的分页结果和我想要的输出。

First Page Result

Next Page Result

My Desired Output When Click Next Page

1 个答案:

答案 0 :(得分:1)

只有当您提交表单时,才会发送$_POST数据,然后点击链接&#34 ;.

所以,你可以这样做:

  • method的{​​{1}}更改为<form>
  • 改为"GET"from的方式(见下注2):

    to
  • 更改您的分页链接:

    $from = isset($_GET['from']) ? $_GET['from'] : '' ; // or change '' to a default initial date. 
    $to = isset($_GET['to']) ? $_GET['to'] : '' ; // or change '' to a default end date.
    
  • 在获取echo '<a href="efms.php?page=' . $page . '&from=' . $from . '&to=' . $to .'">...</a>' ; <input>后,用$from标记来填写这些代码。

    $to

另一种方法可能是将echo '<th><input type="text" name="from" id="from" class="tcal" value="'.$from.'"> to <input type="text" name="to" id="to" class="tcal" value="'.$to.'"><br><br></th>' ; $from存储到$to中,并在发布内容时更改它们。

最后,重要说明

  1. 您应该查看mysqli_prepare()以确保查询SQL injections

  2. 您应该保护输入数据,以防止您的网站被XSS attacks