如何添加在php中自动添加选项的按钮

如何添加在php中自动添加选项的按钮,php,html,button,textarea,Php,Html,Button,Textarea,我在php和html的帮助下创建了一个问题纸,每个问题至少有4个选项,每个选项都存储在数据库中。现在我在一节中感到困惑,我想添加一个按钮,该按钮将为该问题添加更多选项(每次单击该按钮时都会添加更多文本字段),并且这些选项应在这4个选项之后包含在该表中。我试过尝试,但没有成功 这是我的密码: <?php if(isset($_POST['submit'])){ include('dbconfig.php'); $part=$_POST['part']; $que=$_POST['Que']

我在php和html的帮助下创建了一个问题纸,每个问题至少有4个选项,每个选项都存储在数据库中。现在我在一节中感到困惑,我想添加一个按钮,该按钮将为该问题添加更多选项(每次单击该按钮时都会添加更多文本字段),并且这些选项应在这4个选项之后包含在该表中。我试过尝试,但没有成功

这是我的密码:

<?php

if(isset($_POST['submit'])){
include('dbconfig.php');
$part=$_POST['part'];
$que=$_POST['Que'];
$ans1=$_POST['first'];
$ans2=$_POST['second'];
$ans3=$_POST['third'];
$ans4=$_POST['fourth'];
$ans5=$_POST['fifth'];
$ans6=$_POST['sixth'];
$right=$_POST['right'];
$marks=$_POST['marks'];
$tablename=$_REQUEST['table'];
$query="INSERT INTO `tomarproject`.`$tablename` (`qid`, `part`, `Ques`, `firstans`, `secans`, `thirdans`, `fourthans`, `fifthans`, `sixthans`, `RightAns`,`marks`) VALUES (NULL, '$part', '$que', '$ans1', '$ans2', '$ans3', '$ans4', '$ans5', '$ans6', '$right','$marks');";
mysql_query($query) or die(mysql_error());

$query = mysql_insert_id();
 echo $query;
}
else{
if(isset($_POST['finish']))
{
    $message = "Exam Created succesfully!";
header("location:manageexam.php?logout=$message");

    }
}
?

>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin |ExamPaper Page</title>
<style>
body{
    margin:0 0;
    font-family:Tahoma, Geneva, sans-serif;
    font-size:12px;
    color:#036;
    background-color:#CCC}

.wraper{
    background-color:#FFF;
    margin:0 auto;
    width:800px;
    border-left:1px solid #666;
    border-right:1px solid #666;
    height:auto;
    padding:10px;}
ul{
    margin:0 0;}
ul li{
    list-style:none;
}
.header{
    margin-bottom:10px;}
</style>
</head>
<body>
<!--text editor.-->
<script type="text/javascript" src="tinymce/tinymce.min.js"></script>

<script type="text/javascript">tinymce.init({
selector: "textarea",
// ===========================================
// INCLUDE THE PLUGIN
// ===========================================
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste jbimages"
],
// ===========================================
// PUT PLUGIN'S BUTTON on the toolbar
// ===========================================
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
// ===========================================
// SET RELATIVE_URLS to FALSE (This is required for images to display properly)
// ===========================================
relative_urls: false
});</script>

<?php 
$table= $_REQUEST['table'];
include('dbconfig.php');
$query = mysql_query("SELECT * FROM $table");
$numrows = mysql_num_rows($query);

?>

<div class="wraper">
<div class="header"><h1>Create Question for Subject: "<?php echo $_REQUEST['table'];?>"</h1> | Total No. of Questions:&nbsp;&nbsp;<?php echo $numrows;?> &nbsp;&nbsp;| &nbsp;&nbsp;<strong>Total Marks</strong> 
<?php
if(isset($marks))
{
$totalmarks = mysql_query("INSERT INTO examsmeta ('TotalMarks') VALUES ('$marks')");

$lastvalue = mysql_query("SELECT * FROM $table ORDER BY marks ASC") or die('error in query');
$row=mysql_fetch_assoc($query);
echo "Exam Meta: ", $row['marks'];
echo " New Marks: ", $marks;
}
else
echo 0;
?>
</div>
<ul><form action="feedque.php?table=<?php echo $_REQUEST['table'];?>" method="post">
<br>
Part:<input type="text" name="part"/><br>
Question:<textarea id="textarea1" name="Que"></textarea>
<li>1.<textarea class="input" name="first"></textarea></li>
<li>2.<textarea class="input" name="second"></textarea></li>
<li>3.<textarea class="input" name="third"></textarea></li>
<li>4.<textarea class="input" name="fourth"></textarea></li><br />
<input type="submit" name="add" value="Add Options" />
<?php if(isset($_POST['add']))
{ ?>
    <textarea class="input" name=""></textarea>
<?php } ?>
<li>
Right Option: <select name="right">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</li>
<li>Marks for this Question:<input type="text" name="marks"/></li>
<li><input type="submit" value="Submit" name="submit" /></li>
<li><input type="submit" value="Finish" name="finish" /></li>
</form></ul>

</div>
</body>
</html>

您没有为PHP生成的textarea提供任何
名称
。我不知道应该给它取什么名称,而且我认为没有查询将该textarea添加到数据库中。我不知道这之后该怎么办。我对这个按钮太困惑了如果我理解正确,添加的文本区域的数量可能是任何东西?在这种情况下,我建议将所有值添加到一个数组中,并将它们存储在一列中,然后在NeeDeD.DeWork中再次提取所有值。谢谢丹尼尔。考虑将解决方案添加为答案,以便同一问题的人可以看到您是如何做到的。