以下に、質問ごとに各回答を組み合わせたコードを示します。
// $questionNumber is simply n in value[n][]
// $answers is an array of value attributes from <input>s for this question
foreach ($_POST['value'] as $questionNumber => $answers) {
// combine all the answers into a single string (e.g. ACE)
$selected_answer = implode('', $answers);
// continue onto inserting rows into the Answer and Questions tables
// ...
}
したがって、例:
Question 1: Answer: ACE
Question 2: Answer: BD
Question 3: Answer: C
しかし、私は実際に答えを分けて、以下のように表示したいと思います。
Question 1: Answer: A
Question 1: Answer: C
Question 1: Answer: E
Question 2: Answer: B
Question 2: Answer: D
Question 3: Answer: C
だから私の質問は、それがそれらを分離するために私のphpで何を変更する必要があるのかということです?
以下のようになっていると思いますか?
// $questionNumber is simply n in value[n][]
// $answers is an array of value attributes from <input>s for this question
foreach ($_POST['value'] as $questionNumber => $answers) {
// combine all the answers into a single string (e.g. ACE)
$selected_answer = $answers;
// continue onto inserting rows into the Answer and Questions tables
// ...
}