title: ID from another table on insertion using PDO
body: <p>I am creating a quiz based system which part of it includes 2 tables:</p>
  
  <p>Answer_bank table:</p>
  
  <pre><code>+-------+---------+----------+
  | ab_id | ab_name | ab_qb_id |
  +-------+---------+----------+
  </code></pre>
  
  <p>and a Question_bank table:</p>
  
  <pre><code>+-------+-------------+
  | qb_id | qb_question | 
  +-------+-------------+
  </code></pre>
  
  <p>The aim is to allow someone to create a question and an answer, the answer will be stored within the answer bank table with the <code>ab_qb_id</code> equal to the <code>qb_id</code>. I don't want this in the same table as I will be making this more complex.</p>
  
  <p>I try to use the following PDO/SQL to insert into both the tables.</p>
  
  <pre><code>//questions
  $qb_id = $_POST['qb_id'];
  $qb_question = $_POST['qb_question'];
  $sql = "INSERT INTO questions_bank (`qb_id`, `qb_question`)
          VALUES (:qb_id, :qtn)";
  $stmt = $db-&gt;prepare($sql);
  $stmt-&gt;bindValue(":qb_id", $qb_id);
  $stmt-&gt;bindValue(":qtn", $qb_question);
  $stmt-&gt;execute();
  
  //answers
  $ab_name = $_POST['ab_name'];
  $sql = "INSERT INTO answers_bank (`ab_name`, `ab_qb_id`) VALUES (:ab_name, :qb_id)";
  $stmt = $db-&gt;prepare($sql);
  $stmt-&gt;bindValue(':ab_name', $ab_name);
  $stmt-&gt;bindValue(':qb_id', $qb_id);
  $stmt-&gt;execute();
  </code></pre>
  
  <p>However the problem I have is the <code>ab_qb_id</code> in the <code>answer_bank</code> table always inserts <code>0</code> and not the same id as <code>qb_id</code>. Is this the incorrect way to do this? What's the best way for the answer table to include the <code>qb_id</code> ?... So that then the answer is related to a specific question. Thank you</p>