【发布时间】:2019-05-25 20:18:43
【问题描述】:
我创建了一个数据库,其中包含两个表,我从中获取问题并在其中插入答案。现在我只使用这个 index.php 页面中的单选按钮插入了答案
<?php
include "conn.php";
$query="SELECT*FROM questions";
$res=mysqli_query($conn,$query);
?>
<form action="select.php" method="POST">
<?php while($row=mysqli_fetch_assoc($res)){;?>
<p><?php echo $row['question'];?></p>
<input type="radio" name="answ1" value="<?php echo $row['answ1'];?>"><?php echo $row['answ1'];?><br>
<input type="radio" name="answ2" value="<?php echo $row['answ2'];?>"><?php echo $row['answ2'];?><br><br>
<?php };?>
<input type="submit" value="submit" name="submit">
</form>
现在,对于每个问题,我都会查询两个包含两个答案的输入字段。但问题是关于单选按钮的同一个问题可以点击。
我怎样才能避免这个问题,有没有更合适的方式来使用这些表格?
【问题讨论】: