想在分页上加首页和尾页
<?php
extract($_REQUEST);
$n=0;
$query=mysql_query("select count(*) as sm from jiaoshi");
mysql_query("set names 'GB2312'");
$row=mysql_fetch_array($query);
$count=$row['sm'];
if(empty($offset))
{$offset=0;}
/*echo $offset;*/
$where = (! isset($surplus)) ? '' : " where surplus='$surplus'";
$query=mysql_query("select * from jiaoshi $where order by id asc limit $offset,$list_num") or die ("fail");
mysql_query("set names 'GB2312'");
while($row=mysql_fetch_array($query)){
if(($n%2)!='0'){
echo "<tr bgcolor=#CDE6C7>";}
else{
echo "<tr bgcolor=#FFFFFF>";
}
if($row['surplus']==0)
$ss="不可选";
else $ss="可选";
echo"
<td height='22' class='STYLE1'> <div align='center'> ".$row['id']." </div></td>
<td height='22' class='STYLE1'> <div align='center'> ".$row['subject']." </div></td>
<td height='22' class='STYLE1'> <div align='center'> ".$row['teacher']." </div></td>
<td height='22' class='STYLE1'> <div align='center'> ".$row['zhicheng']." </div></td>
<td height='22' class='STYLE1'> <div align='center'> ".$row['number']." </div></td>
<td height='22' class='STYLE1'> <div align='center'> ".$row['xuehao']." </div></td>
<td height='22' class='STYLE1'> <div align='center'>".$ss."</div></td>
<td height='22' class='STYLE1'> <div align='center'> <a href=xiangxiziliao.php?id=".$row['id'].">查看</a></div></td>
</tr> ";
$n++;
}
?>
[解决办法]
$pageno = ceil($offset/$list_num);
ceil 取得 大于等于 $offset/$list_num 的最小整数