Pls 私は助けが必要です。
ページネーションを行ったところ、次のエラーが発生しました。
Notice: Undefined index: sn in C:\xampp\htdocs\SchoolCare\pagination first try.php on line 116
ここに私のコードがあります:
<?php
require "../includes/dc_conect.php";
$sql1=("SELECT * FROM staffs WHERE staff_id='super_admin'");
$result1=mysql_query($sql1, $link) or die (mysql_error());
$dbfield1=mysql_fetch_assoc($result1);
$count1=mysql_num_rows($result1);
$sql=("SELECT COUNT(sn) FROM staffs ORDER BY sn ASC");
$query=mysql_query($sql, $link) or die (mysql_error());
$row=mysql_fetch_row($query);
//here we have the total row counts chyke okoli
$rows= $row[0];
//here is the number of result we wana display chyke okoli
$page_rows= 10;
// this tells us the page number of our last page---chyke okoli
$last = ceil($rows/$page_rows);
//make sure $last cannot be less than 1---chyke
if ($last<1){
$last=1;
}
//establish the $pagenum variable--chike
$pagenum = 1;
//get the page num var from the URL if its present else its equal to 1;
if(isset($_GET['pn'])){
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);
}
//make sure the pagenum is less than 1 and d last is nt more than d last
if($pagenum < 1){
$pagenum = 1;
}elseif($pagenum > $last)
{
$pagenum = $last;
}
//set the range of rows to query -----vitalischikeokoli
$limit = 'LIMIT '.($pagenum - 1) * $page_rows.','.$page_rows;
//write a query to return one page of row
$sql=("SELECT sn, fname, sname, staff_id FROM staffs ORDER BY sn ASC $limit");
$query=mysql_query($sql, $link) or die (mysql_error());
//show the user what page they are into
$textline1 = "Staff Records (<b>$rows</b>)";
$textline2 = "Page <b>$pagenum</b> of <b>$last</b>";
//pagination Ctrl var
$paginationCtrls = '';
//if more than 1 page result
if($last != 1){
/*First we check if we on page one if so we dont need the prev---vitalisokolichike---*/
if($pagenum > 1){
$previous = $pagenum - 1;
$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">PREV</a> ';
//render clickable number link that should appear at d left of the target page num
for($i = $pagenum-4; $i < $pagenum; $i++)
{
if($i > 0){
$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
}
}
}
//render tha target page number without link
$paginationCtrls .=''.$pagenum.' ';
//render d clikable number
for($i = $pagenum+1; $i <= $last; $i++){
$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
if($i >= $pagenum+4){
break;
}
}
//check if we are on the last page then adding NEXT
if($pagenum != $last){
$next = $pagenum + 1;
$paginationCtrls .=' <a href="'.$_SERVER['PHP_SELF'].'?pn='.$next.'">NEXT</a>';
}
}
?>
次に、出力をテーブルにエコーします
<table height="182" id="man_staff_table">
<tr>
<td height="39"><div align="right" id="dboard">
<div id="div2"><a href="../admin/admin_dash_board.php">Dashboard</a></div>
</div></td>
<td height="39"> </td>
<td height="39"> </td>
<td height="39"> </td>
<td height="39"> </td>
<td height="39"> </td>
<td height="39"><div id="dboard"><a href="add_staff.php">Add a Staff</a></div></td>
</tr>
<tr>
<td width="119" height="17"> </td>
<td width="268"> </td>
<td width="13"> </td>
<td width="31"> </td>
<td width="15"> </td>
<td width="195"> </td>
<td width="112"> </td>
</tr>
<tr>
<td height="39" colspan="7"><h3>Manage Staff Records</h3><hr></td>
</tr>
<tr>
<td height="17" colspan="7"><div align="right"><?php echo $textline2; ?></div></td>
</tr>
<tr>
<td height="21" colspan="7"><table width="960" align="center" class="imagetable">
<tr>
<th width="49">S/N</th>
<th width="101">Surname</th>
<th width="118">First Name </th>
<th width="80">Staff ID </th>
<th colspan="4"> </th>
</tr>
<?php do{ ?>
<tr>
<td><?php echo @$row['sn']; ?></td>
<td><?php echo @$row['sname']; ?></td>
<td><?php echo @$row['fname']; ?></td>
<td><?php echo @$row['staff_id']; ?></td>
<td width="273"> </td>
<td width="31"><div align="center"><img src="../image/view_icon.png" alt="View" width="15" height="12"></div></td>
<td width="31"><div align="center"><img src="../image/edit_icon.png" alt="Edit" width="15" height="17"></div></td>
<td width="31"><div align="center"><img src="../image/delete_icon.png" alt="Delete" width="15" height="15"></div></td>
<?php } while($row=mysql_fetch_assoc($query)) ?>
</tr>
</table></td>
</tr>
<tr>
<td height="17" colspan="7"><div align="center" id="pagination_control"><?php echo $paginationCtrls; ?></div></td>
</tr>
</table>
pls i need help.@関数を使用して出力をサイレントにしましたが、その特定の役割は空で見栄えがよくありません![ここに画像の説明を入力][1]