UPDATE! ADDING PHP code
<?php
$tq_array = array();
$c_array = array();
$o1_array = array();
$o2_array = array();
$o3_array = array();
$questions = mysql_query("SELECT * FROM test WHERE exam_code = '$exam'");
while($row = mysql_fetch_assoc($questions)){
$tq_array[] = $row['test_question'];
$c_array[]= $row['correct_answer'];
$o1_array[] = $row['option_1'];
$o2_array[] = $row['option_2'];
$o3_array[] = $row['option_3'];
}
$tq_json = json_encode($tq_array);
$c_json = json_encode($c_array);
$o1_json = json_encode($o1_array);
$o2_json = json_encode($o2_array);
$o3_json = json_encode($o3_array);
?>
my problem is i want to add this converted javascript array (from php array) to another storage.
var questioner = JSON.parse('<?= $tq_json; ?>');
var correct_ans = JSON.parse('<?= $c_json; ?>');
var option1 = JSON.parse('<?= $o1_json; ?>');
var option2 = JSON.parse('<?= $o2_json; ?>');
var option3 = JSON.parse('<?= $o3_json; ?>');
this is the storage where i want to add the codes
var i = 0
for(i = 0; i <= obj1.length;i++){
var questions = [
[ /* this is the one that fix the counting of the questioners*/],
[[obj1[i], obj2[i], obj3[i], obj4[i], obj5[i]],"false",1],
],
sec=20,
A;
}
i try to loop it using for loop but it didnt work.
i like to to appear it like this ()
var questions = [
[ /* this is the one that fix the questioner */],
[[obj1[i], obj1[i], obj1[i], obj1[i], obj1[i]],"false",1],
[[obj2[i], obj2[i], obj2[i], obj2[i], obj2[i]],"false",1],
[[obj3[i], obj3[i], obj4[i], obj3[i], obj3[i]],"false",1],
So on ....
],
sec=20,
A;
Thank you!