PHP Questions with alternativs
===

Hi everybody and thank you in advance. I'm facing a big problem here with PHP and I need your help. I'm creating questions in PHP with alternatives. Every question will have  4 alternatives. Questions will be inserted in one table with name questions and all alternatives will be inserted in another table which called alternatives. Every questions have off course own id's and even every alternative will have own id's too. But every group of alternatives will have question id's too , to know which alternative belongs to which question.  And then I will select them as radio buttons.
For example if we have two questions like
 
 1. What's the name of Australian capital city? (Let's say this question have id nr 1)<br/>
A) Sidney<br/>
B) New Delhi<br/>
C) Canberra<br/>
D) Maimi<br/>
And All those alternatives above will have their own id's and questions id with is 1 in this case.<br>

 2. What is 89 + (3*9) (Let's say this question have id nr 3)<br/>
A) 116 <br/>
B) 117<br/>
C9 115<br/>
D) 112<br/>

And All those alternatives above will have their own id's and questions id with is 3 in this case.<br><br>
 3. An object is dropped from the top of a 100-m-high tower. Its height aboveground after t seconds is 100-4.9t2 m. how fast is it failing 2 sec after is it dropped?<br/>
 A) 98m<br/>
B) 78m<br/>
C) 56m<br/>
D) None of them<br/>
And so on ..... <br>

Here is my code:

    if (isset($_REQUEST['submit']) && $_REQUEST['submit'] != "") {
    $questions = $_POST['questions']; 
     
    $alternatives = $_POST['alternatives']; 
     
    
    if(isset($_POST['questions']) && $_POST['questions'] != '')
    
    {
     
    foreach($questions as $q){
        
        if($q !=''){
    
    $sql1 =	" INSERT INTO questions (question) ".
				" VALUES ('".$q."'); ";
		if (!db_query($sql1))
			$errors['err']='Unable to create question';
   $question_id[] = mysql_insert_id(); 
      }
   
    }
   
   foreach($question_id AS $q_id){ // I think here is the problem but I don't know how to solv'
   
   
     foreach($alternatives as $alt){
       
    
       if($alt !=''){
       $sql =	" INSERT INTO alternatives (alternative, question_id) ".
						" VALUES ('".$alt."', ".$q_id."); ";
                        if (!db_query($sql))
			$errors['err']='Unable to create alternatives';
         }
     
     }
        
     }
  
    }
  
    }
 

 

    <form action="test.php" method="POST" enctype="multipart/form-data"><br /><br /><br />
    for($i=1; $i<=10; ++$i){
    $i.") "?><input type="text" name="questions[]" value="" size="100"/><br />
    <br /><p>Alternatives:</p><br /> 
    for($j=1; $j<=4; ++$j){
    <input type="text" name="alternatives[]" value="" /><br /> } }
    <input type="submit" name="submit" value="Send"></input>
<input class="button" type="reset" value="Reset" />
 

    </form>

Sorry for my code.. it was very difficult to write on here. But what happening is 
All those 12 alternatives inserts three times and each time they get all the same question_id. I mean the first 12 alternatives get question_id nr 1 och then those 12 alternatives inserts again and they get question_id = 2 , and so on.... What I want is the first four alternatives get question_id nr 1, the alternative of the second question would have question_id nr 2 and so on. I don't know how to solve it. I would be grateful if you just could help me to solve this problem. Thank you again.