0

我正在构建一个将数据发布到 MySQL 数据库的表单,我已经完成了所有工作,但是每当我测试它时,只有一个部分的单选按钮的值在数据库中都显示为 0。因此,例如,这会显示表格中填写的任何内容的正确值。

<div class="indented">
            Stronger?
            <input type="radio" name="q4a" value="1" id="q4aY" />
            <label for="q4aY"><span></span>Yes/ </label>
            <input type="radio" name="q4a" value="0" id="q4aN" />
            <label for="q4aN"><span></span>No</label><br />
            More likely to succeed?
            <input type="radio" name="q4b" value="1" id="q4bY" />
            <label for="q4bY"><span></span>Yes/ </label>
            <input type="radio" name="q4b" value="0" id="q4bN" />
            <label for="q4bN"><span></span>No</label><br />
            More known/visible/recognized?
            <input type="radio" name="q4c" value="1" id="q4cY" />
            <label for="q4cY"><span></span>Yes/ </label>
            <input type="radio" name="q4c" value="0" id="q4cN" />
            <label for="q4cN"><span></span>No</label><br />
            <br />
</div>

但是,无论如何,每次填写时都会返回为零。

<table id="section2Table">
            <thead>
                <tr>
                    <th scope="colgroup" colspan="4">Before ELP</th>
                    <th scope="col">Activities that support Entrepreneurship</th>
                    <th scope="colgroup" colspan="4">Now</th>
                </tr>
                <tr>
                    <th>Yearly</th>
                    <th>Quarterly</th>
                    <th>Monthly</th>
                    <th>Weekly</th>
                    <th></th>
                    <th>Yearly</th>
                    <th>Quarterly</th>
                    <th>Monthly</th>
                    <th>Weekly</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><input type="radio" name="7_1b" value="1" id="1yearlyb" />
                    <label for="1yearlyb"><div align="center"></div></label></td>
                    <td><input type="radio" name="7_1b" value="4" id="1quarterlyb" />
                    <label for="1quarterlyb"><div align="center"></div></label></td>
                    <td><input type="radio" name="7_1b" value="12" id="1montlyb" />
                    <label for="1montlyb"><div align="center"></div></label></td>
                    <td><input type="radio" name="7_1b" value="52" id="1weeklyb" />
                    <label for="1weeklyb"><div align="center"></div></label></td>
                    <td class="q7question">Strategically lead others as a member of an advisory board or board of directors (company or NGO, including JA, chamber)</td>
                    <td><input type="radio" name="7_1n" value="1" id="1yearlyn" />
                    <label for="1yearlyn"><div align="center"><span id="check"></span></div></label></td>
                    <td><input type="radio" name="7_1n" value="4" id="1quarterlyn" />
                    <label for="1quarterlyn"><div align="center"><span id="check"></span></div></label></td>
                    <td><input type="radio" name="7_1n" value="12" id="1montlyn" />
                    <label for="1montlyn"><div align="center"><span id="check"></span></div></label></td>
                    <td><input type="radio" name="7_1n" value="52" id="1weeklyn" />
                    <label for="1weeklyn"><div align="center"><span id="check"></span></div></label></td>
                </tr>

我不确定我在这里缺少什么,发布页面上的 PHP 代码都是一样的,如果你想看一下,我会发布它,但所有变量都以相同的方式标识。我很想得到一些帮助,因为我对这些东西很陌生。谢谢!

4

2 回答 2

1

通过w3c 验证器运行您的 HTML 。你会发现相当多的错误。其中之一是(其中不止一个):

value of attribute "ID" invalid: "1" cannot start a name 
    <input type="radio" id="1yearlyb" value="1" name="7_1b">
                            ^

125: 属性 Y 的值无效:X 不能开始一个名字

您可能违反了此属性的命名约定。例如,id 和 name 属性必须以字母开头,而不是数字。

似乎也有div'inside labels 被指出为无效。我建议您修复 HTML 中的语法错误,然后从那里重试。

我不知道这是否能解决您的问题,但符合标准绝不是一个坏主意。

这是一个不错的沙盒环境,您可以在其中尝试、设置有问题的情况并让我们对其进行调试。

于 2013-06-16T21:44:54.110 回答
0

属性值不是按钮的当前状态。

相反,如果它被选中,它是单选按钮的值。

示例:如果选择了单选按钮,并且定义的值为 YES,那么在 php 中您将收到 YES,但如果未选择,您将不会收到任何内容。

于 2013-06-16T21:14:48.900 回答