我原来在一个表中最前面加了一列复选框,现在我想以数组的形式读 出复选框的值,并显示被选中的复选框后面的一条记录,
请各位大侠给点意见

解决方案 »

  1.   

    <input type="checkbox" name="c[]">1
    <input type="checkbox" name="c[]">2
    <input type="checkbox" name="c[]">3<?php
    $count = count($_POST['c']);
    echo $_POST['c'][$count-1]; //3
    ?>
      

  2.   

    <input type="checkbox" name="c[]">1
    <input type="checkbox" name="c[]">2
    <input type="checkbox" name="c[]">3能不能改为不固定的个数啊,就是用数组那样的,因为我的那个表是用数组输出的,行数挺多
      

  3.   

    是不是按纽的意思啊,我刚学,很多不明白,请前辈多多指教,
    for($n = 0; $n < 8; $n++)
    {<input type="checkbox" name="c[]" value="1">}
    输出的只有一个,我想得到所有的,可以吗
      

  4.   

    <?php
    var_dump($_POST);
    ?>
      

  5.   

    不知道该怎么跟你讲,参考代码:
    <script language=Javascript>
    function checkAll(e, itemName)
    {
      var aa = document.getElementsByName(itemName);
      for (var i=0; i<aa.length; i++)
       aa[i].checked = e.checked;
    }
    function checkItem(e, allName)
    {
      var all = document.getElementsByName(allName)[0];
      if(!e.checked) all.checked = false;
      else
      {
        var aa = document.getElementsByName(e.name);
        for (var i=0; i<aa.length; i++)
         if(!aa[i].checked) return;
        all.checked = true;
      }
    }
    </script>
    <form action="query.php" method="post" name="form1">
        <table width="98%" border="0">        <tr> 
                <td valign="top" nowrap>指定用户</td>
                <td nowrap><table width="462" border="0">
                        <tr> 
                            <td width="44" height="16">选择</td>
                            <td width="180">公司名</td>
                            <td width="107">用户名</td>
                            <td width="113">用户姓名</td>
                        </tr>

    <?php while ($row_user = $result_user->fetchRow(DB_FETCHMODE_ASSOC)) { ?>
    <tr>
                            <td height='16'><input name="selectIt[]" type="checkbox" id="selectIt[]" value="<?php echo $row_user['user_id'] ?>"></td>
                            <td><?php echo $row_user['user_category'] ?></td>
                            <td><?php echo $row_user['user_uid'] ?></td>
    <td><?php echo $row_user['user_name'] ?></td>
                        </tr>
                        <?php } ?>
                    </table></td>
            </tr>
    <tr><td>&nbsp;</td>
    <td colspan="2" nowrap> 
    <input type=checkbox name=mmAll onClick="checkAll(this, 'selectIt[]')">全选与反选切换
    </td></tr>
            <tr> 
                <td colspan="2" nowrap> <input type="submit" name="Submit" value="提交"> 
                    <input name="Reset" type="reset" id="Reset" value="重置"> </td>
            </tr>
      </table>
    </form>
      

  6.   

    wasuka和wwx840723讲的很好啊!楼主好好看看。