0
我正在嘗試使用PHP創建分頁,嘗試每頁顯示5條記錄。一切正常,但是當我點擊分頁鏈接轉到下一頁時,它會顯示一條錯誤消息。訪問禁止的錯誤
訪問被禁止!
您沒有權限訪問請求的對象。它是 讀取保護或服務器不可讀取。
如果您認爲這是服務器錯誤,請與網站管理員聯繫。
錯誤403
本地主機的Apache/2.4.25(Win32的)的OpenSSL/1.0.2j PHP/30年6月5日
這裏是我的代碼。
<?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>
通過查看您的源代碼,您應該能夠清楚地看到您創建鏈接網址的方式錯誤 –