我的代码中有一个问题,当我导航链接时,我的分页不起作用,它的生成通知错误未定义索引:package name。这是我的密码:
include("includes/header.php");
include('php_script/db.php');
$package_name = $_GET['package_name'];
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 1;
$offset = ($pageno-1) * $no_of_records_per_page;
$result = mysqli_query($con,$total_pages_sql);
$total_rows = mysqli_fetch_array($result)[0];
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql = "select * from tour_package where package_name
='".$package_name."'
order by id desc LIMIT $offset, $no_of_records_per_page ";
$res_data = mysqli_query($con,$sql);
以下是分页链接:
<ul class="pagination">
<li><a href="?pageno=1">First</a></li>
<li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".
($pageno - 1); } ?>">Prev</a> </li>
<li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?
pageno=".($pageno + 1); } ?>">Next</a></li>
<li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
1条答案
按热度按时间13z8s7eq1#
试试这个