0) // student exists already, update their data $query = "UPDATE students SET school_id = '".$_POST['school_id']."', teacher_id = '".$_POST['teacher_id']."', gender = '".$_POST['gender']."', aboriginal = '".$_POST['aboriginal']."', first_init = '".$_POST['first_init']."', last_init = '".$_POST['last_init']."', division = '".$_POST['division_id']."' WHERE student_id = '".$_POST['student_id']."'"; else // student does not exist, enter them into the system $query = "INSERT INTO students SET student_id = '".$_POST['student_id']."', school_id = '".$_POST['school_id']."', teacher_id = '".$_POST['teacher_id']."', gender = '".$_POST['gender']."', aboriginal = '".$_POST['aboriginal']."', first_init = '".$_POST['first_init']."', last_init = '".$_POST['last_init']."', division = '".$_POST['division_id']."'"; mysqli_query($dbh, $query); // get questions that are part of this test so we can get the answers correlated. $query = "SELECT * FROM questions WHERE test_id = '".$test_id."' AND info_question <> 'Y' ORDER BY question_rank, question_id"; $result = mysqli_query($dbh, $query); while ($question = mysqli_fetch_array($result)) { $query = "INSERT INTO results SET student_id = '".$_POST['student_id']."', question_id = '".$question['question_id']."', answer_id = '".$_POST[$question['question_id']]."', testing_date = NOW()"; mysqli_query($dbh, $query); } echo '

Thank you for completing the assessment.

'; echo '

Return to School District #71

'; } ?>