gpt4 book ai didi

php - 单选按钮选择不在 MYSQL 中发布

转载 作者:行者123 更新时间:2023-11-29 05:30:03 25 4
gpt4 key购买 nike

enter image description here我正在使用一些 html 和 php 将一些数据发布到 mysql 数据库中。我在发布广播时遇到了一些困难。我想我搞砸了我在我的 php 和数据库中声明它的方式。我已将 radio 定义为 tinyint。这是我的 PHP

$value = $_POST['name'];
$value2 = $_POST['email'];
$value3 = $_POST['address'];
$value4 = $_POST['city'];
$value5 = $_POST['state'];
$value6 = $_POST['zip'];
$value7 = $_POST['primary'];

$sql = "INSERT INTO demo (name, email, address, city, state, zip, primary) VALUES ('$value', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7')";

html

<div id="options">
<div class="opt1"><input type="radio" name="primary" value="Color" /></div>
<div class="opt2"><input type="radio" name="primary" value="Dry" /></div>
<div class="opt3"><input type="radio" name="primary" value="Damaged" /></div>
<div class="opt4"><input type="radio" name="primary" value="Thinning" /></div>
</div>

我有其他表单元素作为文本字段,它们正在运行

最佳答案

您的问题(我相信)是由使用 intval() 引起的.

您传递的值是一个字符串 - Color、Dry、Damaged 或 Thinning。

如果你想传递一个整数给$value7 - 将 html 中单选按钮的值更改为所需的结果。

例如: <div class="opt1"><input type="radio" name="primary" value="1" /></div>

关于php - 单选按钮选择不在 MYSQL 中发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15800980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com