我使用PHP和SQL完成了这个分页。第2页模块中缺少id 11和12。我无法找出我在做错的地方。请在下面找到源代码
<?php
$per_page = 5;
$rec_count = $row['id'];
$total_pages = ceil($rec_count / $per_page);
if (isset($_GET['page'])) {
$show_page = $_GET['page']; //current 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;
$sql = "SELECT COUNT(Id) AS id FROM [Register].[dbo].[RegisData] WHERE DeleteStatus = 1";
$result = sqlsrv_query($conn,$sql);
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$rec_count = $row['id'];
$total_pages = ceil($rec_count / $per_page);
$sql1 = "SELECT [Id],[FirstName],[LastName],[ProfilePic],[Gender]
,[Email],[MobileNo],[Company],[Designation],[Country],[State],[Address],[City]
,[Pincode],[Hobbies],[DietaryHabits],[DeleteStatus]
FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY RegId) as row
FROM [Register].[dbo].[RegisData])
a WHERE row between $start and $end
AND DeleteStatus = 1
ORDER BY RegId";
$result = sqlsrv_query($conn,$sql1);
$z = 1;
for ($x=1; $x<=$total_pages; $x++) {
echo $x;
}
?>
请在我犯错的地方帮助我。