Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 执行多行更新时,如何访问除复选框之外的其他表单元素值?_Php_Mysql_Html - Fatal编程技术网

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

Php 执行多行更新时,如何访问除复选框之外的其他表单元素值?,php,mysql,html,Php,Mysql,Html,我编写了一段代码,根据勾选的复选框执行多行删除。 现在我需要对它进行改造,以进行多行更新。 我无法访问每行的文本框值 总的来说,这是我的代码 <?php if (isset($_POST["SaveComments"]) && isset($_POST["SaveEachComment"])) { while(list($key, $val) = each($_POST["SaveEachComment"])) { if($val == '

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

总的来说,这是我的代码

<?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>


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

<?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>

我在您的PHP代码中没有看到任何可以引用文本框的内容。