【发布时间】:2018-01-29 20:47:13
【问题描述】:
美好的一天!我的分页有问题,我的分页将显示从日期(2018 年 1 月 1 日)到日期(2018 年 1 月 31 日)之间的数据,在第一页它工作正常。当我单击下一页时,结果消失了,我必须重新输入日期之间的数据。这是我的分页代码。
<th><input type="text" name="from" id="from" class="tcal"> to <input type="text" name="to" id="to" class="tcal"><br><br></th>
<th><input type="submit" class="button" value=""></th>
<?php
$con = mysqli_connect('localhost','root','');
mysqli_select_db($con, 'efms');
$results_per_page = 20;
$from=@$_POST['from'];
$to=@$_POST['to'];
$sql="SELECT *, SUM(rqty), SUM(iqty), SUM(bbal), COUNT(item), COUNT(description) FROM issuances WHERE trandate BETWEEN '$from' AND '$to' GROUP BY item, description, category ORDER BY item, description, category ASC";
$result = mysqli_query($con, $sql);
$number_of_results = mysqli_num_rows($result);
$number_of_pages = ceil($number_of_results/$results_per_page);
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
$this_page_first_result = ($page-1)*$results_per_page;
$from=@$_POST['from'];
$to=@$_POST['to'];
$sql="SELECT *, SUM(rqty), SUM(iqty), SUM(bbal), COUNT(item), COUNT(description) FROM issuances WHERE trandate BETWEEN '$from' AND '$to' GROUP BY item, description, category ORDER BY item, description, category ASC LIMIT " . $this_page_first_result . ',' . $results_per_page;
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($result)) {
$id=$row['id'];
$item=$row['item'];
$description=$row['description'];
$rqty=$row['SUM(rqty)'];
$iqty=$row['SUM(iqty)'];
$bqty=$row['bqty'];
$bbal=$row['SUM(bbal)'];
$totqtyb=$bbal+$rqty-$iqty;
echo "<th width='80px' class='text-left left bottom right'>$item ($description)</th>";
echo "<th width='80px' class='right bottom'>$bbal</th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='80px' class='right bottom'>$rqty</th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='100px' class='right bottom'>$rqty</th>";
echo "<th width='80px' class='right bottom'>$iqty</th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='100px' class='right bottom'></th>";
echo "<th width='100px' class='right bottom'>$totqtyb</th>";
echo "</tr>";
}
for ($page=1;$page<=$number_of_pages;$page++) {
echo '<b><a href="efms.php?page=' . $page . '"> ' . $page . ' </a></b>';
}
?>
我的分页结果和我想要的输出。
【问题讨论】:
-
没有
$_POST数据在您“点击链接”时发送,仅在您提交表单时发送。 -
我该怎么办?
标签: php jquery pagination