title: How to Add a button that will automatically add options in php
body: <p>I am creating an Question Paper with the help of php and html, each Question has Minimum 4 Options and each Option gets Stored in database. Now i am confused in a section, I Want to add a button that will add more option (more text field on each click on that button) for that question and also those option should be included into that table after those 4 options. I have tried to attempt but didn't get success in that.</p>
  
  <p>Here is My Code :</p>
  
  <pre><code>&lt;?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");
  
      }
  }
  ?
  
  &gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Admin |ExamPaper Page&lt;/title&gt;
  &lt;style&gt;
  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;}
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;!--text editor.--&gt;
  &lt;script type="text/javascript" src="tinymce/tinymce.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;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
  });&lt;/script&gt;
  
  &lt;?php 
  $table= $_REQUEST['table'];
  include('dbconfig.php');
  $query = mysql_query("SELECT * FROM $table");
  $numrows = mysql_num_rows($query);
  
  ?&gt;
  
  &lt;div class="wraper"&gt;
  &lt;div class="header"&gt;&lt;h1&gt;Create Question for Subject: "&lt;?php echo $_REQUEST['table'];?&gt;"&lt;/h1&gt; | Total No. of Questions:&amp;nbsp;&amp;nbsp;&lt;?php echo $numrows;?&gt; &amp;nbsp;&amp;nbsp;| &amp;nbsp;&amp;nbsp;&lt;strong&gt;Total Marks&lt;/strong&gt; 
  &lt;?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;
  ?&gt;
  &lt;/div&gt;
  &lt;ul&gt;&lt;form action="feedque.php?table=&lt;?php echo $_REQUEST['table'];?&gt;" method="post"&gt;
  &lt;br&gt;
  Part:&lt;input type="text" name="part"/&gt;&lt;br&gt;
  Question:&lt;textarea id="textarea1" name="Que"&gt;&lt;/textarea&gt;
  &lt;li&gt;1.&lt;textarea class="input" name="first"&gt;&lt;/textarea&gt;&lt;/li&gt;
  &lt;li&gt;2.&lt;textarea class="input" name="second"&gt;&lt;/textarea&gt;&lt;/li&gt;
  &lt;li&gt;3.&lt;textarea class="input" name="third"&gt;&lt;/textarea&gt;&lt;/li&gt;
  &lt;li&gt;4.&lt;textarea class="input" name="fourth"&gt;&lt;/textarea&gt;&lt;/li&gt;&lt;br /&gt;
  &lt;input type="submit" name="add" value="Add Options" /&gt;
  &lt;?php if(isset($_POST['add']))
  { ?&gt;
      &lt;textarea class="input" name=""&gt;&lt;/textarea&gt;
  &lt;?php } ?&gt;
  &lt;li&gt;
  Right Option: &lt;select name="right"&gt;
  &lt;option value="1"&gt;1&lt;/option&gt;
  &lt;option value="2"&gt;2&lt;/option&gt;
  &lt;option value="3"&gt;3&lt;/option&gt;
  &lt;option value="4"&gt;4&lt;/option&gt;
  &lt;option value="5"&gt;5&lt;/option&gt;
  &lt;option value="6"&gt;6&lt;/option&gt;
  &lt;/select&gt;
  &lt;/li&gt;
  &lt;li&gt;Marks for this Question:&lt;input type="text" name="marks"/&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="submit" value="Submit" name="submit" /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="submit" value="Finish" name="finish" /&gt;&lt;/li&gt;
  &lt;/form&gt;&lt;/ul&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please Help me Out Through These, Any Help Would Be Appreciated Thanks.</p>