我将答案值发送到answer
表中。我用下面的代码做到这一点。请看一下,让我知道我在哪里做错了,我是 php 新手。我想将问题编号和答案值添加到表中。
<?php
//connects to database
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("appulentoweb", $con);
//retrieve data from database
$result = mysql_query("SELECT * FROM questions"); ?>
<form action="questioned.php" method="post">
<table>
<tr>
<th> QNo</th>
<th> QTitle </th>
<th> QAnswer </th>
</tr>
<?php
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['qid'];?></td>
<td><?php echo $row['qdesc'];?></td>
<td><input type="text" name="answervalue" /></td>
</tr>
<?php
$sql="INSERT INTO mobilestrgy (qno,response) VALUES ('$_POST[qid]','$_POST[answervalue]')";
?>
<?php } ?>
</table>
<input type="submit" value="Submit"/>
</form>
我想将数据提交到数据库。提前致谢。