这个页面是一个可以正常显示列表的页面,单击“下一页”时,页数会发生变化,但是页面内容还是显示的第一页。系统提示第72和79行未定义变量Undefined variable: php_self 我应该怎样修改下? 
<?php
/*error_reporting(E_ALL ^ E_NOTICE);*/
//######################课题列表##########################
  include "config.php";
  include "header.php";
?> 
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"><link href="style.css" rel="stylesheet" type="text/css">
<title>课题列表</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 14px}
-->
</style>
<table width="740" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">
  <tr> 
  <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="text">  <p class="STYLE1">课题编号</p></div> </td>
  <td width="300" height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">课题名称</div>    </td>
  <td width="85"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">指导教师</div></td>
  <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">职称</div>    </td>
  <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">可选人数</div>    </td>
  <td width="80"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">选题情况</div>    </td>
  <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">状态</div>    </td>
  <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">详细资料</div>    </td>
  </tr>
<?php
  $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;
   $query=mysql_query("select * from jiaoshi 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=#ffffff>";}
  else{
  echo "<tr bgcolor=#E4E4E4>";
  }
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++;
   }
   ?></table>
   
 <?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=\"$php_self?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=\"$php_self?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>";
   ?>   
   <p>
   </p>
<?php include "foot.php";?>

解决方案 »

  1.   

    $_SERVER[PHP_SELF]
    不写也可以
      

  2.   

    是不是把那两行里面的$php_self?删除吗?我删除以后点下一页后直接就“无法找到该网页”了……
      

  3.   

    好吧,我输给你了。我就是把71、79行的$php_self?删除了再运行的。<?php/*error_reporting(E_ALL ^ E_NOTICE);*///######################课题列表##########################  include "config.php";  include "header.php";?> <meta http-equiv="Content-Type" content="text/html; charset=GB2312"> <link href="style.css" rel="stylesheet" type="text/css"><title>课题列表</title><style type="text/css"><!--.STYLE1 {font-size: 14px}--></style><table width="740" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">  <tr>   <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="text">  <p class="STYLE1">课题编号</p></div> </td>  <td width="300" height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">课题名称</div>    </td>  <td width="85"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">指导教师</div></td>  <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">职称</div>    </td>  <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">可选人数</div>    </td>  <td width="80"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">选题情况</div>    </td>      <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">状态</div>    </td>  <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">详细资料</div>    </td>  </tr><?php  $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;   $query=mysql_query("select * from jiaoshi 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=#ffffff>";}      else{      echo "<tr bgcolor=#E4E4E4>";      }    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++;   }   ?></table>     <?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>";   ?>      <p>   </p><?php include "foot.php";?>
      

  4.   

    怎么会变成一行的?我重新粘<?php
    error_reporting(E_ALL ^ E_NOTICE);
    //######################课题列表##########################
      include "conn.php";
      include "header.php";
    ?> 
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312"><link href="style.css" rel="stylesheet" type="text/css">
    <title>课题列表</title>
    <style type="text/css">
    <!--
    .STYLE1 {font-size: 14px}
    -->
    </style>
    <table width="740" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">
      <tr> 
      <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="text">  <p class="STYLE1">课题编号</p></div> </td>
      <td width="300" height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">课题名称</div>    </td>
      <td width="85"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">指导教师</div></td>
      <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="STYLE1">职称</div>    </td>
      <td width="60"  height="30"  bgcolor="#FFFFFF"> <div align="center" class="title STYLE1">可选人数</div>    </td>
      <td width="80"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">选题情况</div>    </td>
      <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">状态</div>    </td>
      <td width="60"  height="30"  bgcolor="#FFFFFF" class="title"><div align="center" class="STYLE1">详细资料</div>    </td>
      </tr>
    <?php
      $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;
       $query=mysql_query("select * from jiaoshi 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=#ffffff>";}
      else{
      echo "<tr bgcolor=#E4E4E4>";
      }
    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++;
       }
       ?></table>
       
     <?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>"; 
       ?>  
       
       <p>
       </p>
    <?php include "foot.php";?>
      

  5.   

    对了,需要说明一下,我那个$list_num已经提前定义了。
      

  6.   

    你真够可以的
    print("<td width='158'><a  href=\"$php_self?offset=$newoffset\">下一页</a></td>");
    说是 $php_self 可以不要
    你却
    print "<td width='132'><a href=\"offset=$preoffset\">上一页</a></td>";}
    连 ? 也不要了
      

  7.   

    那我现在修改成print "<td width='132'><a href=\"?offset=$preoffset\">上一页</a></td>";}和 print("<td width='158'><a  href=\"?offset=$newoffset\">下一页</a></td>");
    加了?后,到是不报错了,但是下一页还是第一页的内容啊~~~~
      

  8.   

    不知是谁教你用 error_reporting(E_ALL ^ E_NOTICE); 回避矛盾的
    这枚不负责任!
    你的 $offset 在哪里赋值的?
    既然你没有 $offset = $_GET['offset'];
    那么目标偏移如何能传入?
    既然不能传入,那翻页如何实现?
      

  9.   

    版主息怒,版主明察秋毫。确实我没有赋值,我应该字哪里赋值?我把那句话加进来了,系统又提示第63行有 Undefined index: offset  <?php
        extract($_REQUEST);
    $offset = $_GET['offset'];
        $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>"; 
       ?>  
      

  10.   

    既然你已经有了 extract($_REQUEST);
    那么 $offset = $_GET['offset']; 就不需要了,何况如果是 post 表单提交,就没有 $_GET['offset']你是在 php5 下调试一个按 php4 一般工作环境书写的项目,那么肯定会出现一些问题。
    但你实际上没有修改代码的能力,这一点从无法解决未定义变量的问题就可看出在你的前几个帖子中,我都明确的告诉你了:在程序的开始处加上 extract($_REQUEST); 就可以了
    这样做的目的就在于:在没有了魔术变量的情况下,使用 php4 的项目至于本轮的 $php_self 问题,显然是你自己制造的!
    如果是原来就有的,那么就是 $PHP_SELF 而不是 $php_self(注意:php的变量名是区分大小写的)
      

  11.   

    版主,由于我的水平以及档次问题,一次次地很烦地每天在论坛里问一些弱智的问题,这个是我在做的毕业设计,被逼得没办法了,周围同学也没有会PHP的,在6月2好答辩前,小女子可能还会多次烦您,望您见谅了!