有人可以帮助我吗,我正在尝试实施一个简单的php MySQL调查,但我坚持这个,我如何在用户选择的MySQL中存储特定的选择。
你有多满意:
<table id="table1" rules="all" border="1" cellpadding="3" cellspacing="0" width="70%">
<colgroup width="70%"></colgroup>
<colgroup width="6%">
</colgroup>
<thead>
<tr align="center">
<th></th>
<th font="" style="font-size:9pt;" size="2"><b>Dissatisfied</b></th>
<th font="" style="font-size:9pt;" size="2"><b>Satisfied</b></th>
<th font="" style="font-size:9pt;" size="2"><b>Very Satisfied</b></th>
</tr>
</thead>
<tbody>
<tr align="center">
<td align="left"><font style="font-size:10pt;"><b>Technician's ability to understand the unique nature of your problem?</b></font></td>
<td><input name="satisfaction" value="Dissatisfied" type="radio"></td>
<td><input name="satisfaction" value="Satisfied" type="radio"></td>
<td><input name="satisfaction" value="Very Satisfied" type="radio"></td>
</tr>
<tr align="center">
</tbody>
</table>
答案 0 :(得分:2)
为此您需要表单来提交数据选择。你需要两个php文件
第一个是构建一种单选按钮。我删除了表格元素以获得整洁的视图,然后我们设置了第二页的URL。如果需要,也可以是单页,但这样更容易。
feedback.php
<form action="add.php" method="post" accept-charset="utf-8">
<input name="satisfaction" value="Dissatisfied" type="radio">Dissatisfied<br>
<input name="satisfaction" value="Satisfied" type="radio">Satisfied<br>
<input name="satisfaction" value="Very Satisfied" type="radio">Very Satisfied<br>
<input type='submit' value="submit">
</form>
在第二页中,我们会抓住从第一页发布的内容。
add.php
$result= $_POST['satisfaction'];
echo $result;
使用$ result存储在您的数据库中。祝你好运
答案 1 :(得分:1)
简单如下:
1,在表格标签前添加此行:
<form method="post" action="">
2,代码末尾的这个:
<input type="submit" name="submit" value="Submit">
</form>
然后您可以使用此代码插入数据库。
if ($stmt = $mysqli->prepare("INSERT INTO TABLENAME(COLUMN NAME) values (?)")) {
$stmt->bind_param('s', $satisfaction);
$satisfaction=$_POST['satisfaction'];
$stmt->execute();
$stmt->close();
}