小编Jus*_*oss的帖子

PHP处理多个复选框

好的,我的index.html表格如下:

<form action="process.php" method="post">
  <table>
    <tr>
      <td><input name="Field[]" type="checkbox" value="Accounting" />Accounting</td>
      <td><input name="Field[]" type="checkbox" value="Finance" />Finance</td>
      <td><input name="Field[]" type="checkbox" value="Marketing" />Marketing</td>
    </tr>
  </table>
</form>
Run Code Online (Sandbox Code Playgroud)

我有process.php如下:

<table>
  <tr>
    <th>Field(s):</th>
    <td>
      <?php
        if(isset($_POST['Field']))
        {
          for($i = 0; $i < count($_POST['Field']); $i++)
          { echo $_POST['Field'][$i] . ' '; }
        }
      ?>
    </td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,我只得到打印出来的最后一个复选框的第一个字母.请帮忙!

php-5.3

1
推荐指数
1
解决办法
2429
查看次数

标签 统计

php-5.3 ×1