Php 有没有一种方法可以提交一个表格,每行有两个输入作为列表?

Php 有没有一种方法可以提交一个表格,每行有两个输入作为列表?,php,codeigniter,Php,Codeigniter,我有以下表格: <tbody> <tr> <th>ID</th> <th>Name</th> <th>Birthdate</th> <th><input type="text" autofocus="autofocus" name="textinput1"/></th> <th><inpu

我有以下表格:

 <tbody>
    <tr>
     <th>ID</th>
     <th>Name</th>
     <th>Birthdate</th>
     <th><input type="text" autofocus="autofocus" name="textinput1"/></th>
     <th><input type="checkbox" name="checkinput[]" value="1"/></th>
    </tr>
    <tr>
     <th>ID</th>
     <th>Name</th>
     <th>Birthdate</th>
     <th><input type="text" autofocus="autofocus" name="textinput2"/></th>
     <th><input type="checkbox" name="checkinput[]" value="1"/></th>
    </tr>
    (...and so on...)
  </tbody>

身份证件
名称
生日
身份证件
名称
生日
(……等等……)

当我单击submit按钮时,是否有一种方法可以将post数据设置为数组类型,其中每个索引都有复选框值和文本输入?这样,我只需迭代数组,并为表单中的每一行检查数据库中的相应行并进行更新。

将文本输入框放入数组,并将数组键的值放入HTML:

<th><input type="text" autofocus="autofocus" name="textinput[1]"/></th>
<th><input type="checkbox" name="checkinput[]" value="1"/></th>
请注意,这不会告诉您是否选中了复选框,因为只有选中的复选框才会从浏览器发送到服务器。要执行此操作,请修改复选框,使其也包含数组键:

<th><input type="checkbox" name="checkinput[1]" value="1"/></th>

复选框的值完全相同。你能举一个你想要的数组结构的例子吗?我想这是一个输入错误,第二个
checkinput[]
框的值应该是2。我有20行,每行是一个学生,在一些行中我会选中复选框和/或写入文本输入,其他我只是在文本输入中输入并保留复选框,其他我不检查并写入。这就是为什么我想把这些数据作为一个数组发布,其中每个索引都是学生的ID,在每个索引中我都有文本框和复选框的值。类似这样的$rows[index][checkbox]$rows[index][textbox]如果我写了这个,所有的复选框都会被提交吗?即使是未选中的?不。只有选中的复选框才会被提交。
<th><input type="checkbox" name="checkinput[1]" value="1"/></th>
foreach( $input as $checkbox_value => $text_input_value) {
     echo $checkbox_value . ' ' . $text_input_value;
     $checked = (isset( $_POST['checkinput'][$checkbox_value])) ? 'checked' : 'not checked';
     echo "\nThe checkbox was $checked\n";
}