I tried to create pagination with database iteration. This is my code so far.
$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');
that. Since it makes following error.
Warning: mysqli_fetch_array() expects at most 2 parameters, 3 given in..
Can someone help me to solve this error.