Hello,
I have a question/
I want to get the selected value from a form without submit, and then to use this selected values in another php file.
i think if i can put the values in array, and then to register the array on a session, and the to use this array ob the another php file, but it doesn"t working.
this is part of the code:
$i=0;
$arrayAns = Array();
while ($row = mysql_fetch_array($result))
{
echo "<form action='' name='myForm' id='myForm' method='post'> <table dir='rtl' bgcolor='white' border='1' width='90%'>";
echo "<tr><th width='10%'>question number: " . $row['ques_no'] . "</th>";
echo "<td>the question: " . $row['ques_body'] . "</td></tr>";
echo "<tr><th width='10%'>1:</th><td>" . $row['ansr1'] . "</td></tr>";
echo "<tr><th width='10%'>2:</th><td>" . $row['ansr2'] . "</td></tr>";
echo "<tr><th width='10%'>3:</th><td>" . $row['ansr3'] . "</td></tr>";
echo "<tr><th width='10%'>4:</th><td>" . $row['ansr4'] . "</td></tr>";
echo "<tr><th width='10%'>choose answer:</th><th align='right'><select name='corr'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
</select></th></tr>";
echo "</table></form>";
$arrayAns[i]=$_POST['corr'];
$i++;
}
session_register($arrayAns);
and this is part of the another php file code:
$sql = "SELECT * FROM $tbl_name WHERE exam_no='$examnum' and chapter_no='$chap'";
$result = mysql_query($sql);
$quest_num=0;
$answers=$_SESSION[$arrayAns];
while ($row = mysql_fetch_array($result))
{
$ques_num = $row['ques_no'];
$corr_ans = $row['correct_ansr'];
$user_ansr=$answers[$quest_num];
$query = "INSERT INTO $tbl_name2 VALUES ('$user','$examnum','$chap','$ques_num','$corr_ans','$user_ansr')";
mysql_query($query) or die(mysql_error());
$quest_num++;
}
$_SESSION['chap']++;
header("location:exam.php");
I hope to help me, Thank you :)