在 php.ini中把 register_globals = Off 修改成 On就不问你要查询条件了!是你没有搞清楚PHP版本的问题,现在不赞成这样做了,都用楼上的方法!

解决方案 »

  1.   

    我修改了php.ini的,不过还是不行
      

  2.   

    我参考了http://topic.csdn.net/t/20040330/10/2902685.html
    但是始终不能解决
      

  3.   

    <?
    //####################用户查询库中的书##########################
    include "config.php";
    include "admin_header.php";
    include "admin_auth.php";
    mysql_query("SET NAMES gb2312");   
    ?> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="style.css" rel="stylesheet" type="text/css">
    <?
    $baht_baid=$_POST['baht_baid'];
    $baht_baperson=$_POST['baht_baperson'];
    $baht_saltcom=$_POST['baht_saltcom'];
    $baht_basecom=$_POST['baht_basecom'];
    if($search){
    if(empty($baht_baid)&&empty($baht_saltcom)&&empty($baht_basecom)&&empty($baht_baperson)){
    echo "请输入查询条件0"; 
    exit;
    }
    $sqlba="select * from $baht_table where 1=1";
    if($baht_baid) {$sqlba=$sqlba." and baht_baid like '%$baht_baid%' ";}
    if($baht_saltcom) {$sqlba=$sqlba." and baht_saltcom like '%$baht_saltcom%'";}
    if($baht_basecom) {$sqlba=$sqlba." and baht_basecom like '%$baht_basecom%'";}
    if($baht_baperson){$sqlba=$sqlba." and baht_baperson='%$baht_baperson%'";}
    $query=mysql_query($sqlba); 
     $n=0; 
     $row=mysql_fetch_array($query);
       $count=mysql_num_rows($query);
          if(empty($offset))
                  {$offset=0;}
    ?>
    <table width="770" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">
      <tr class="style1"> 
        <td width="80" bgcolor="#FFFFFF"><div align="center" class="text">备案号</div>
        </td>
        <td width=165 bgcolor="#FFFFFF"><div align="center" class="text">盐厂</div>
        </td>
        <td width="165" bgcolor="#FFFFFF"><div align="center" class="text">碱厂</div>
        </td>
        <td width=60 bgcolor="#FFFFFF"><div align="center" class="text">备案数量</div>
        </td>
        <td width="100" nowrap bgcolor="#FFFFFF"><div align="center" class="text">开始时间</div>
        </td>
        <td width="100" bgcolor="#FFFFFF"><div align="center" class="text">结束时间</div>
        </td>
        <td width=60 bgcolor="#FFFFFF" class="title"><div align="center" class="text">备案状态</div>
        </td>
        <td width=31 bgcolor="#FFFFFF" class="title"><div align="center" class="text">查看</div>
        </td>
      </tr>
    <?
       $query=mysql_query($sqlba." order by baht_id desc limit $offset,$list_num") or die ("fail");
       while($row=mysql_fetch_array($query)){
            if(($n%2)!='0'){
        echo "<tr bgcolor=#FFFFff>";}
      else{
      echo "<tr bgcolor=#E4E4E4>";
      }
         echo"<td   height='15' class='text'> <div align='center'>".$row['baht_baid']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_saltcom']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_basecom']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_banum']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_starttime']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_stoptime']."</div></td>
        <td   height='15' class='text'> <div align='center'>".$row['baht_bastate']."</div></td>
        <td   height='15' class='text'> <div align='center'>
        <a href=admin_ba_see.php?baht_id=".$row['baht_id'].">查看</a></div></td>
      </tr> ";
       $n++;
       }
    ?>
    </table>
    <?
        $pages=ceil($count/$list_num);
    echo "<table width=770 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>";
      }
      else{
    ?><table width="770" border="0" cellspacing="1" cellpadding="0" class="text" bgcolor="#000000" align="center">
      <!--DWLayoutTable-->
      <form method="post" action="admin_ba_search.php">
        <tr bgcolor="#E4E4E4"> 
          <td class="text" width="116">按备案号:</td>
          <td width="297" height="30"> <input type="text" name="book_name"> </td>
          <td width="73">按盐厂:</td>
          <td width="279" height="30"> <input type="text" name="pub_addr"> </td>
        </tr>
        <tr> 
          <td bgcolor="#FFFFFF">按碱厂:</td>
          <td bgcolor="#FFFFFF" height="20"> <input type="text" name="author"> </td>
          <td bgcolor="#FFFFFF">按备案人:</td>
          <td bgcolor="#FFFFFF" height="30"> <input type="text" name="sort_id"> </td>
        </tr>
        <tr bgcolor="#E4E4E4"> 
          <td height="25" colspan="4" valign="top" bgcolor="#FFFFFF"> <div align="center"> 
              <input type="hidden" name="search" value="查  询" >
              <input type="submit"  value="查  询" class="text">
            </div></td>
        </tr>
        <tr bgcolor="#E4E4E4"> 
          <td height="17" colspan="4" valign="top" bgcolor="#FFFFFF"> <font color="#FF0000"> 
             *请选择上边的任一种查询条件或选择多个条件进行查询有关内容。</font></td>
        </tr>
      </form>
    </table>
    <?}?>
    <?include "foot.php";?>
      

  4.   

    把 register_globals = On 修改回来Off, 重启服务器!$baht_baid=$_POST['baht_baid'];
    $baht_baperson=$_POST['baht_baperson'];
    $baht_saltcom=$_POST['baht_saltcom'];
    $baht_basecom=$_POST['baht_basecom'];换成 @extract($_POST);看看!你看你改了后那个$search变量还是没有管啊!