I am trying to create Pagination using PHP, trying to show 5 records per page. Everything works just fine but when I click Pagination links to go to the next page it show an error message.
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
Here is my code.
<?php
define("SPP", 5);
if(isset($_GET['groupname']) && isset($_GET['uniname'])) {
/* VARS */
$xpage = 0;
$content = null;
$totalProfile;
$totalPage = 0;
if(isset($_GET['xpage'])) { $xpage = $_GET['xpage']; }
$start = $xpage*SPP;
$end = $start+SPP;
include("protected/config.php");
include("protected/class.db.php");
include("protected/publicLang.php");
$newSearch = new DB();
$newSearch->query("SELECT username, university,bgroup, (SELECT COUNT(id) FROM donors) AS totalProfile FROM donors WHERE bgroup = :bgroup LIMIT " . $start . ", " . $end . " ");
$newSearch->exec(array(
":bgroup" => $_GET['groupname']
));
$data = $newSearch->fetch();
foreach($data as $row) {
$totalProfile = $row['totalProfile'];
$content .= '
<tr>
<td>' . $row['username'] . '</td>
<td>'.$row['university'].'</td>
<td>' . convertBloodIdPublic($row['bgroup']) . '</td>
<td><button class="btn btn-success">Contact</button></td>
</tr> ';
}
$totalPage = round($totalProfile/SPP); }
?>
<div class="container records">
<table>
<tr>
<th>--</th>
<th>--</th>
<th>--</th>
<th>--</th>
</tr>
<?php echo $content ?>
</table>
<ul class="pagination">
<?php
for($i=1; $i<=$totalPage; $i++) {
echo '<li><a href="<?php echo ' . $_SERVER['REQUEST_URI'] . '"&xpage"' . $i . ' ?>">' . $i . '</a></li>';}
?>
</ul>