日期:2014-05-17  浏览次数:20473 次

再一次厚脸皮…………分页…………页面跳转后还是当前页面
 <?php
    extract($_REQUEST);
    $pages=ceil($count/$list_num);
       echo "<table width=760 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
          <tbody> 
          <tr> 
     <td width='159'><font color='#ff0000'>目前共有".$count."条记录</font> </td>
    <td width='205'>共".$pages."页</td>";
 
  if($offset){
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"?offset=$preoffset\">上一页</a></td>";}
else {
  echo "<td width='132'>上一页</td>";
}
 $newoffset=$offset+$list_num;
  if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
 print("<td width='158'><a  href=\"?offset=$newoffset\">下一页</a></td>");
}
 else{ echo "<td width='158'>下一页</td>";}
$pageno=($offset/$list_num)+1;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>
      页</td>
    <td width='4'>&nbsp;</td></tr>
</table>"; 
   ?>  
   

------解决方案--------------------
你把 61 行的 extract($_REQUEST); 调到 32 行之前,甚至可以放在 header.php 或 conn.php
否则由于 $offset 并未赋值,if(empty($offset)) 恒成立