i hope i can explain my problem 🙂
$count = 0; while( have_rows('wordpress_acf_plugin_variable',$id) ) : the_row(); $count++; $cevapsecenek .='<b>Question '.$count.'</b>: <input type="radio" name="question_'.$count.'" value="A"> A <input type="radio" name="question_'.$count.'" value="B"> B <input type="radio" name="question_'.$count.'" value="C"> C <input type="radio" name="question_'.$count.'" value="D"> D <br>'; endwhile;
frontend screen for this code;
Question 1: () A () B () C () D Question 2: () A () B () C () D . . .
and when member(student) send submit button.
$scount = 0; $studenquestionanswers = array(); while( have_rows('wordpress_acf_plugin_variable',$id) ) : the_row(); $scount++; ${'question_'.$scount} = $_POST['question_'.$scount]; $answers = get_sub_field('answersfrom_acf_plugin_variable'); if(${'question_'.$scount}==$answers) { $trueanswers += 1; } else { $wronganswers += 1; } $emptyanswers = $scount - ($trueanswers + $wronganswers); $studenquestionanswers[] = $_POST['question_'.$scount]; endwhile;
my problem only this code
$studenquestionanswers[] = $_POST['question__'.$scount];`
i want insert student’s answers to database like “ABCD”
Advertisement
Answer
if u want to combine all answers in one string you can join them. After while loop write:
$studenquestionanswers = join('', $studenquestionanswers);