I've worked on this the entire night. Finally, after two weeks, I came up with these codes:
<?php
if(@$_POST['submit'])
{
$select_paragraph=mysql_query('SELECT * FROM dependency');
$questrows = 0;
while(mysql_fetch_array($select_paragraph))
{
$counter = 0;
$select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"');
$rows = mysql_num_rows($select_question);
while($counter < $rows){
echo "<br>";
@$b=$_POST['Option'.$questrows];
$s="insert into temp(StudId, TestId, ItemId, LiteralId, Choice) values(1, 3, $questrows,'','$b')";
mysql_query($s);
$counter++;
$questrows++;
}
}
header("Location: validate.php");
}
?>
It solved my problem. @blacknight: Thanks anyway for the help.