我想将分页添加到呈现动态数据的页面。但是当我点击页面链接(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