<?php
include("../class/conn.php");
$cid=$_POST['slt'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>项目管理系统</title>
</head><body>
<form name="form1" method="post" action="admin-glxm.php">
  <table width="200" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        <select name="slt" id="slt">
          <?php
           $db=db_connect();
           $sql="select * from `title`";
           $rs=$db->query($sql);
           while($row=mysqli_fetch_array($rs))
                {
          ?>
        <option value="<?=$row[id]?>"><?=$row[title]?></option>
          <?
                }
          ?>
        </select>
        </td>
      </tr>
        <?
$bid=$cid;
$db=db_connect();
$sql="select * from `s_title` where t_id='$bid'";
$rs=$db->query($sql);
while($row=mysqli_fetch_array($rs))
{
        ?>
        <td><?=$row[s_title]?></td>
        </tr> 
        <?
}
?>  
  </table>
</form>
</body>
</html>我怎么获取不了<select name="slt" id="slt">的值

解决方案 »

  1.   

    没有提交动作怎么能用$_POST获区呢?
      

  2.   

    admin-glxm.php文件中$_POST['slt']; 就可以获取吧
      

  3.   

    <input type="submit" name="tijiao" value="提交">提交一下啦
      

  4.   

    我不需要提交按钮,我只要显示的结果,那我怎么能获取select里面的值呢
      

  5.   

    用JS获取,如果你不用提交按钮的话。var value=document.getElementById('slt').value;
      

  6.   


    <?
    include("../class/conn.php");
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>项目管理系统</title>
    </head><body>
    <form name="form1" method="post" action="admin-glxm.php">
      <table width="200" border="1" cellspacing="0" cellpadding="0">
          <tr>
            <td>
            <select name="slt" id="slt">
              <?php
               $db=db_connect();
               $sql="select * from `title`";
               $rs=$db->query($sql);
               while($row=mysqli_fetch_array($rs))
                    {
              ?>
            <option value="<?=$row[id]?>"><?=$row[title]?></option>
              <?
                    }
              ?>
            </select>
            </td>
          </tr>
            <?
            $bid='<script>document.write(document.getElementById(\'slt\').value)';
            $sql="select * from `s_title` where t_id='$bid'";
            $rs=$db->query($sql);
            while($row=mysqli_fetch_array($rs))
            {
            ?>
            <td><?=$row[s_title]?></td>
            </tr> 
            <?
            }
            ?>  
      </table>
    </form>
    </body>
    </html>
      

  7.   

    按照你写的,报错
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\xmglxt\admin\2.php on line 34
      

  8.   

    echo $bid;//看看这个是什么?
      

  9.   

    你在做二级联动吧,你可以用AJAX啊