<?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++;
}
?>
------解决方案--------------------
print "<td width='170'><a href=\"?offset=1\">首页</a></td><td width='170'><a href=\"?offset=$preoffset\">上一页</a></td>";}
print("<td width='170'><a href=\"?offset=$newoffset\">下一页</a></td><td width='170'><a href=\"?offset=$count\">尾页</a></td>");
居然两个print语句的写法不一样……唉,进步空间很大
------解决方案--------------------
$pageno=floor(($offset/$list_num)+1); //改成这样呢