title: fetch data from a table and save it in another table
body: <p>i want to save data from table into another table. i am using flask,  it keeps getting me this error &gt;
  werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
  KeyError: 'studentTFQuestion'</p>
  <p>i tried to make the fetch into  &amp;  tags but still no success. i guess because these tags inside  because i am using table format thus, it cannot read  &amp;  tags.</p>
  <p>is there a way to save the inputs other than this way?</p>
  <p>this is test.html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;test&lt;/title&gt;
        &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body &gt;
  &lt;h2&gt;Answer The Following Question&lt;/h2&gt;
  &lt;form action = &quot;{{ request.path }}&quot; method=&quot;POST&quot;&gt;
  
      &lt;br&gt;
   &lt;table style=&quot;border: 1px solid black;&quot;&gt;
           &lt;thead&gt;
              &lt;tr  style=&quot;border: 20px solid black ;&quot;&gt;
                 &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;TF Question&lt;/th&gt;
                 &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;TF Answer&lt;/th&gt;
                 &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;MCQ Question&lt;/th&gt;
                 &lt;th  style=&quot;border: 1px solid black ; display:none;&quot;&gt;MCQ Answer&lt;/th&gt;
                  &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;Option A&lt;/th&gt;
                  &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;Option B&lt;/th&gt;
                  &lt;th  style=&quot;border: 1px solid black ;&quot;&gt;Option C&lt;/th&gt;
              &lt;/tr&gt;
           &lt;/thead&gt;
  
           &lt;tbody&gt;
              {% for question in quickQuizQuestions %}
                 &lt;tr style=&quot;border: 1px solid black;&quot;&gt;
                     &lt;td  style=&quot;border: 1px solid black;&quot;&gt;&lt;input type=&quot;text&quot; id=&quot;studentTFQuestion&quot; value=&quot; {{ question.TFquestion }}&quot; readonly&gt;&lt;/td&gt;
                    &lt;td style=&quot;border: 1px solid black;&quot;&gt;
                        True &lt;input type=&quot;radio&quot; id=&quot;T&quot; name=&quot;TFquestion&quot; value=&quot;T&quot;&gt;
                        False &lt;input type=&quot;radio&quot; id=&quot;F&quot; name=&quot;TFquestion&quot; value=&quot;F&quot;&gt;
                        &lt;/td&gt;
                     &lt;td style=&quot;border: 1px solid black;&quot;&gt;&lt;input type=&quot;text&quot; id=&quot;MCQquestionTd&quot; value=&quot;{{ question.MCQquestion }}&quot; readonly&gt;&lt;/td&gt;
                    &lt;td style=&quot;border: 1px solid black; display:none;&quot;&gt;{{ question.MCQanswer }}&lt;/td&gt;
                     &lt;td style=&quot;border: 1px solid black;&quot;&gt;(A) &lt;input type=&quot;radio&quot; id=&quot;a&quot; name=&quot;MCQquestion&quot; value=&quot;A&quot;&gt;{{ question.OptionA }}&lt;/td&gt;
                     &lt;td style=&quot;border: 1px solid black;&quot;&gt;(B) &lt;input type=&quot;radio&quot; id=&quot;b&quot; name=&quot;MCQquestion&quot; value=&quot;B&quot;&gt;{{ question.OptionB }}&lt;/td&gt;
                     &lt;td style=&quot;border: 1px solid black;&quot;&gt;(C) &lt;input type=&quot;radio&quot; id=&quot;c&quot; name=&quot;MCQquestion&quot; value=&quot;C&quot;&gt;{{ question.OptionC }}&lt;/td&gt;
                 &lt;/tr&gt;
              {% endfor %}
           &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;br&gt;
      &lt;input type=&quot;submit&quot; id=&quot;studentSubmit&quot; name=&quot;studentSubmit&quot; value=&quot;Submit&quot;&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>this is app.py</p>
  <pre><code>#questions table
  class quickQuizQuestions(db.Model):
      def __init__(self, TFquestion, TFanswer, MCQquestion, MCQanswer, OptionA, OptionB, OptionC):
          self.TFquestion = TFquestion
          self.TFanswer = TFanswer
          self.MCQquestion = MCQquestion
          self.MCQanswer = MCQanswer
          self.OptionA = OptionA
          self.OptionB = OptionB
          self.OptionC = OptionC
      id = db.Column('question_id', db.Integer, primary_key=True)
      TFquestion = db.Column(db.String(900))
      TFanswer = db.Column(db.String(1))
      MCQquestion = db.Column(db.String(900))
      MCQanswer = db.Column(db.String(1))
      OptionA = db.Column(db.String(1))
      OptionB = db.Column(db.String(1))
      OptionC = db.Column(db.String(1))
  
  #students answers table
  class studentAnswerTable(db.Model):
      def __init__(self, TFquestion, studentAnswer, MCQquestion, Option):
          self.TFquestion = TFquestion
          self.studentAnswer = studentAnswer
          self.MCQquestion = MCQquestion
          self.Option = Option
          # answers=[studentAnswer('{{ question.TFquestion }}', 'TFquestion', '{{ question.MCQquestion }}', 'MCQquestion')]
          # table = studentAnswer('answers')
      id = db.Column(db.Integer, primary_key=True)
      # student_id = password
      TFquestion = db.Column(db.String(900))
      studentAnswer = db.Column(db.String(1))
      MCQquestion = db.Column(db.String(900))
      Option = db.Column(db.String(1))
  
  @app.route('/test', methods=['GET', 'POST'])
  def test():
       if request.method == 'POST':
          if request.form['studentSubmit']:
             question = studentAnswerTable(request.form['studentTFQuestion'], request.form['TFquestion'], request.form['MCQquestionTd'], request.form['MCQquestion'])
             db.session.add(question)
             db.session.commit()
             flash('Record was successfully added')
             return render_template(&quot;studentAnswer.html&quot;)
  
          else:
              flash('Please enter all the fields', 'error')
  
       return render_template(&quot;test.html&quot;, quickQuizQuestions=quickQuizQuestions.query.order_by(-quickQuizQuestions.id).limit(1).all())
  </code></pre>