我想將分頁添加到呈現動態數據的頁面。但是當我點擊頁面鏈接(1,2,3等)時,我會得到以下錯誤信息。我相當新的PHP,請協助。在第4行 通知\瓦帕\ WWW \ HR \ HR_Applicants.php::未定義指數:作業ID在C:\瓦帕\ WWW \ HR \ HR_Applicants.php上線動態數據中的分頁
說明:未定義指數:作業ID用C 8 警告:mysql_result()期望參數1是資源,在第18行的C:\ wamp \ www \ HR \ HR_Applicants.php中給出的布爾值 注意:使用未定義的常量mysql_error - 在C:\ wamp中假定'mysql_error' \在下面第4行的誤差線28
所有錯誤WWW \ HR \ HR_Applicants.php的發生是因爲當的JobID我分頁點擊鏈接(即1,2,3等)失去它的值。最初當頁面加載時,它着陸在正常(未分頁的頁面)上,並且工作正常。點擊分頁鏈接時出現問題。
下面是分頁頁面的代碼。
<?php
session_start();
print_r($_GET, true);
print_r($_REQUEST['Jobid']);
require 'scripts/connect.php';
//Get the Person's jobid
$jobid = $_GET['Jobid'];
//the number of rows to show per page
$per_page = 2;
//Count the number of items in the database
$pages_query = mysql_query("SELECT COUNT('Personid') FROM person where jobid=$jobid");
//Round the number of pages to the nearest 10
$pages = ceil(mysql_result($pages_query,0)/$per_page);
//Check if there value of page is set
$page = (isset($_GET['page'])) ?(int)$_GET['page']: 1;
//Start counting from zero
$start = ($page -1)* $per_page;
//Select the data from the datbase, but limit it to the number of item per page
$Personid_query ="SELECT * FROM person where jobid=$jobid LIMIT $start ,$per_page";
$Personid = mysql_query($Personid_query) or die(mysql_error);
$row = mysql_fetch_assoc($Personid);
?>
上面的代碼是正確的頂端,也就是HTML標籤之前。以下代碼屬於HTML標記,因爲向用戶顯示的數據是動態的,並且從找到'jobid'的數據庫中選擇。
<fieldset>
<?php do{?>
<p><a href="Resume.php?Personid=<?php echo $row['Personid'];?>"><?php echo $row['Personid']?></a></p>
<?php echo $row['Title'];?> <?php echo $row['Forename']?> <?php echo $row['Surname']?> <?php echo $row['ApplicationDate'];?>
<?php }while ($row = mysql_fetch_assoc($Personid))?>
<br />
<?php
//Show the pagination links at the bottom of the page
if ($pages >= 1 && $page<= $pages)
{
for($i=1;$i<=$pages;$i++)
{
echo '<a href="?page='.$i.'">'.$i.'</a> ';
}
}
?>
</fieldset>
感謝戴爾。有用。我是PHP的新手,所以我仍然在學習很多東西。感謝您的幫助 – user1783675
不用擔心冠軍,很高興我能幫上忙 – Dale