title: save id with the selected answer in php
body: <p>Am trying to save the result of the the selected answer with the question id. don't know how to pass the id to the DB. here's my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  session_start();
  include('config/manpower_db.php');
  
  $sql = mysql_query("SELECT * FROM question") or die(mysql_error());
  $i = '1';
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form action="save_feedback.php" method="post"&gt;
  &lt;H2&gt; How Will You Rate This Service&lt;/H2&gt;
  
  &lt;?php
  while($row = mysql_fetch_array($sql))
  {
  
  echo  $row['question'];
    
   // $comp = $row['id'][$i];
    
   // $_SESSION['comp']= $comp;
  
  ?&gt;
  &lt;br /&gt;
  &lt;?php
  
  
  echo "&lt;td&gt; &lt;input type='radio' name='answer[".$row['id']."]'  value='1' &gt;1";
  echo "&lt;td&gt; &lt;input type='radio' name='answer[".$row['id']."]'  value='2' &gt;2";
  echo "&lt;td&gt; &lt;input type='radio' name='answer[".$row['id']."]'  value='3' &gt;3";
  echo "&lt;td&gt; &lt;input type='radio' name='answer[".$row['id']."]'  value='4' &gt;4";
  echo "&lt;td&gt; &lt;input type='radio' name='answer[".$row['id']."]'  value='5' &gt;5";
  
  
  echo'&lt;br/&gt;';
  $i++;
  }
  ?&gt;
  &lt;br/&gt;
  
  &lt;strong&gt; NOTE:&lt;/strong&gt; 1 - Very Poor, 2 - poor, 3 - Okay, 4 - Fair, 5 - Good
  &lt;p&gt;
  
  &lt;input name="submit" type="submit" value="submit" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Save to DB</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  session_start();
  
  $answer  = $_POST['answer'];
  
  include('config/manpower_db.php');
  
  
     
     foreach($hobb as $key=&gt;$val)
  {
      $var1=$hobb[$key];
      $var2=$answer[$key];
     
           
              //include ('connect.php');
     //include ('mysql_connect.php');
              $table = "INSERT INTO answer (answer) ".
                       "VALUES ('$var2')";
              mysql_query($table) or die(mysql_error());
              $inserted_fid = mysql_insert_id();
              mysql_close();  
          }
  
    
  
  echo'&lt;script&gt;alert("Inserted Successfully")&lt;/script&gt;'; 
  
     
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This works but am trying to save the question id. don't know how to pass that to the database. 
  thanks in advance</p>