$question = array(); for ($i = 0; $i < $_POST['questionCount']; $i++) { if (isset($_POST['question_' . $i])) { if (isset($_POST['uq' . $i])) { $question_id = $quiz->updateQuestion($_POST['question_' . $i], $_POST['uq' . $i], $member->id); } else { $question_id = $quiz->addQuestion($_POST['question_' . $i], $member->id); } } // Quiz Options for ($j = 0; $j < $questionArray[$i]; $j++) { if (isset($_POST['q' . $i . 'o' . $j]) && isset($_POST['q' . $i . 'r' . $j]) && isset($_POST['q' . $i . 'w' . $j])) { if (isset($_POST['uq' . $i . 'o' . $j])) { $quiz->updateOption($_POST['q' . $i . 'o' . $j], $_POST['q' . $i . 'r' . $j], $_POST['q' . $i . 'w' . $j], $_POST['uq' . $i . 'o' . $j], $member->id); } else { $quiz->addOption($_POST['q' . $i . 'o' . $j], $_POST['q' . $i . 'r' . $j], $_POST['q' . $i . 'w' . $j], $question_id, $member->id); } } } } // check the direction to go if ($_POST['save'] == "Previous Part") { header("Location: ../webroot/modifyQuiz.php?step=2&id=" . $quiz_id); } else { header("Location: ../webroot/modifyQuiz.php?step=4&id=" . $quiz_id); } break; case 4: // final step // get the id from the form $quiz_id = $_POST['id'];