[英]PHP pagination not working properly
I have written a PHP script to display 5 records per page. 我写了一个PHP脚本,每页显示5条记录。
My Problem :- When I type individual page no. 我的问题:-当我键入单个页面号时。 in browser it works perfectly fine and display information page by page but it is not showing page numbers at bottom of page.
在浏览器中,它工作得很好,并且可以逐页显示信息,但是在页面底部不显示页码。
I have also observed that $sql returns no result, where as the same $sql is working fine when used above in the same script above somewhere. 我还观察到$ sql不返回结果,因为在上面的同一脚本中的同一位置使用相同的$ sql可以正常工作。
Thanks for help in advance. 预先感谢您的帮助。
Here is my script for pagination which is not working 这是我的分页脚本不起作用
<div>
<?php
//Now select all from table
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE did>0".$search_string.$search_dlocation." order by did desc";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
// Count the total records
$total_records = mysqli_num_rows($sql_result);
//Using ceil function to divide the total records on per page
$total_pages = ceil($total_records / $per_page);
//Going to first page
echo "<center><a href='displaydesign.php?page=1'>".'First Page'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='displaydesign.php?page=".$i."'>".$i."</a> ";
};
// Going to last page
echo "<a href='displaydesign.php?page=$total_pages'>".'Last Page'."</a></center> ";
?>
</div>
check this line 检查这行
$total_records = mysqli_num_rows($sql_result);
it should be: 它应该是:
$total_records = mysql_num_rows($sql_result);
you are using mysqli instead of mysql . 您正在使用mysqli而不是mysql 。
However try to use mysql i as mysql is currently deprecated and removed in PHP7 但是,请尝试使用mysql i,因为php7已弃用并删除了mysql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.