插入单选按钮的选择到MySQL [英] Inserting the selection of radio buttons into MySQL

查看:153
本文介绍了插入单选按钮的选择到MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可惜我一直没能找到正是我要找的在线解决这个问题。

Unfortunately I haven't been able to find exactly what I'm looking for online to resolve this.

在任何情况下,我有三个单选按钮,我需要推从列表中选择到MySQL的单一按钮的选择。

At any rate, I have three radio buttons and I need to push the selection of a single button selected from the list into MySQL.

目前使用下面我的单选按钮和放大器;提交:

Currently using the below as my radio buttons & submit:

   <input class="radiobutton" type="radio" name="1" id="1">1</div>
   <input class="radiobutton" type="radio" name="2" id="2">2</div>
   <input class="radiobutton" type="radio" name="3" id="3">3</div>
   <input type="submit" name="submit" value="Update">`

有人可以帮助我的语法抢选定的单选按钮,并将其插入到MySQL?

Can someone help me with the syntax to grab the selected radio button and insert it into MySQL?

的语法的一个例子是
        UPDATE tblwhatever.setting设定值='$ X'的地方设置='Y';

An example of the syntax would be UPDATE tblwhatever.setting SET value='$x' where setting='Y';

推荐答案

考虑以下几点:

<input class="radiobutton" type="radio" name="radio" id="1" value="1" onclick="document.getElementById('2').checked = false;"/>
<input class="radiobutton" type="radio" name="radio" id="2" value="2" onclick="document.getElementById('1').checked = false;"/>

请注意,我给他们同样的名称属性。当表单提交,我们将检索 $ _ POST ['无线电'] 将决定哪个单选按钮是选中。如果选择了的onclick 属性会取消选中另一个单选按钮..例如:如果无线 ID =1是正在检查取消选中 ID =2

Note that i gave them the same name attribute. When the form is submitted we will retrieve $_POST['radio'] and the value will determine which radio button was selected. The onclick attribute will uncheck the other radio button if selected.. eg: if radio id="1" is being checked uncheck id="2"

这篇关于插入单选按钮的选择到MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆