php - 如何通过表格中的表单发送复选框状态

标签 php html forms checkbox html-table

下面的表单包含一个带有复选框作为输入类型的表格 当我执行 _POST 的 var_dump 时,每个复选框的值都没有通过

<form method="post" action="index.php?option=com_content&view=article&id=3" name="details" >
        <div id="table_container">   
        <table class="z">
            <thead>
                <tr>
                    <th>Select</th>
                    <th>Last Name</th>
                    <th>First Name</th>
                    <th>Street Num</th>
                    <th>Street Name</th>
                    <th>City</th>
                    <th>State</th>
                    <th>Zip</th>
                    <th>Phone</th>
                </tr>
            </thead>
            <tbody>
                <?
                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                    ?>  
                    <tr>
                        <td style="text-align: center; vertical-align: middle;">
                            <input type="checkbox" name="<?echo $row['UUID'];?>">    
                        </td>
                        <td><?echo $row['last_name'];?></td>
                        <td><?echo $row['first_name'];?></td>
                        <td><?echo $row['street_num'];?></td>
                        <td><?echo $row['street_name'];?></td>
                        <td><?echo $row['city'];?></td>
                        <td><?echo $row['state'];?></td>
                        <td><?echo $row['zip'];?></td>
                        <td><?echo $row['phone'];?></td>                        
                    </tr>
                    <?                  
                }
                ?>
            </tbody>
        </table>
        </div>
        <input type="hidden" id="type" name="type" value="4">
            <input type="submit" value="Place On Hold">
        </form>

最佳答案

所以我认为你想要做的是这个。如果我理解正确的话。

<input type="checkbox" name="UUID[]" value="<?echo $row['UUID'];?>">

现在,当您发布页面时,您将在 POST 中拥有一个名为 UUID 的数组,其中每个 UUID 都被选中。

关于php - 如何通过表格中的表单发送复选框状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24098975/

相关文章:

php - Android - 通过 Http 获取 json 数据并列出它们

php - 数据库更新需要FROM子句,但是FROM子句导致错误

php - 转义 <?使用 require 时在启用 php 速记的服务器上

javascript - 如何将 html 标签 id 转换为 php 字符串

javascript - 无法使用数字键盘输入数字

javascript - 有什么方法可以通过返回键从 &lt;textarea&gt; 提交表单吗?

php - Symfony php zip 文件下载时有零字节

html - 跨浏览器 OGG 音频

html - 固定表格

ruby-on-rails - Rails 3和fields_for与activemodel(无表)对象