执行多行更新时,如何访问除复选框之外的其他表单元素值


when perfoming a multiple row updates, how do i access other form element values, apart from the checkbox?

我写了一段代码,根据勾选的复选框进行多行删除。现在我需要对它进行媒介化以进行多行更新。我一直无法访问每一行的文本框值。

总的来说,这是我的代码。

<?php
if (isset($_POST["SaveComments"])  && isset($_POST["SaveEachComment"]))
{
    while(list($key, $val) = each($_POST["SaveEachComment"]))
    {
        if($val == 'commentbox')
        {
            // do the update here. $val contains the ID
        }
    }
}
?>
<form id="form1" name="form1" method="post" action="test.php">
    <input type="checkbox" <?php echo 'name="SaveEachComment['.$row["comment"].']" ';?> value="commentbox" id="commentbox" />
    <input type="text" name="rowcomment" size="55" value="<?php echo $comment;?>" />
    <input type="submit"   name="SaveComments" value="submit"  />
</form>

我刚刚添加了一个for循环来打印多个表单字段。显然,您的迭代将与行数一样多,所以您可以更改代码的这一部分。但试试这个:

<?php
if (isset($_POST["SaveComments"])  && isset($_POST["SaveEachComment"]))
{
    while(list($key, $val) = each($_POST["SaveEachComment"]))
    {
        if($val == 'commentbox')
        {
                echo $_POST['rowcomment'][$key] . "<br />'n";
            // do the update here. $val contains the ID
        }
    }
}
?>
<form id="form1" name="form1" method="post" action="test.php">
<?php for ($i=0; $i<11; $i++) { ?>
    <input type="checkbox" <?php echo 'name="SaveEachComment['.$i.']" ';?> value="commentbox" id="commentbox" />
    <input type="text" name="rowcomment[<? echo $i?>]" size="55" value="<?php echo $comment;?>" />
        <br />
<?php } ?>
    <input type="submit"   name="SaveComments" value="submit"  />
</form>