最多2个参数我试图创建一个数据库迭代分页。这是我的代码到目前为止。警告:mysqli_fetch_array()预计在PHP
$per_page = 5;
$result = mysqli_query($connection,"SELECT * FROM inquiries");
$total_records = mysqli_num_rows($result);
$total_pages = ceil($total_records/$per_page);
if (isset($_GET['page'])) {
$show_page = $_GET['page'];
if ($show_page > 0 && $show_page <= $total_pages) {
$start = ($show_page - 1) * $per_page;
$end = $start + $per_page;
} else {
$start = 0;
$end = $per_page;
}
} else {
$start = 0;
$end = $per_page;
}
$page = intval($_GET['page']);
$tpages=$total_pages;
if ($page <= 0)
$page = 1;
for ($i = $start; $i < $end; $i++) {
if ($i == $total_records) {
break;
}
echo mysqli_fetch_array($result,$i,'message');
那。由于它造成以下错误。
警告:mysqli_fetch_array()预计至多2个参数,在3给出..
有人可以帮我解决这个错误。
在查询中使用LIMIT start,count进行分页。 – Barmar
另外,考虑使用'而($行= $ result-> FETCH_ASSOC())' – Machavity
但我想通过做 'for' 循环。否则分页将无法正常工作 –