\n"; } else { echo $coreCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } //update elective class history for this student for($count = 0; $count < sizeof($electCourses); $count++) { $takenElect = $_POST['takenElect' . $count]; if($takenElect === "Yes") { $yesOrNo = 1; } else { $yesOrNo = 0; } if($_POST['electCourse' . $count . 'Semester'] === 'Spring' || $_POST['electCourse' . $count . 'Semester'] === 'Summer' || $_POST['electCourse' . $count . 'Semester'] === 'Fall' || $_POST['electCourse' . $count . 'Semester'] === 'Winter' && isset($_POST['electCourse' . $count . 'Semester'])) { $semesterElect = $_POST['electCourse' . $count . 'Semester']; } else { $semesterElect = 'N/A'; } $updateElectClassesQuery = "INSERT INTO ElectiveHistory (studentID, courseID, semester, completed)" . "VALUES (" . $studentID . ", '". $electCourses[$count] . "', '" . $semesterElect . "', " . $yesOrNo . ")"; if(mysqli_query($connect, $updateElectClassesQuery)) { echo $electCourses[$count] . ' was updated for student ' . $studentID . "'s history.
\n"; } else { echo $electCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } //update cognate classes for this student for($count = 0; $count < sizeof($cognCourses); $count++) { $takenCogn = $_POST['takenCogn' . $count]; if($takenCogn === "Yes") { $yesOrNo = 1; } else { $yesOrNo = 0; } if($_POST['cognCourse' . $count . 'Semester'] === 'Spring' || $_POST['cognCourse' . $count . 'Semester'] === 'Summer' || $_POST['cognCourse' . $count . 'Semester'] === 'Fall' || $_POST['cognCourse' . $count . 'Semester'] === 'Winter' && isset($_POST['cognCourse' . $count . 'Semester'])) { $semesterCogn = $_POST['cognCourse' . $count . 'Semester']; } else { $semesterCogn = 'N/A'; } $updateCognClassesQuery = "INSERT INTO CognateHistory (studentID, courseID, semester, completed)" . "VALUES (" . $studentID . ", '". $cognCourses[$count] . "', '" . $semesterCogn . "', " . $yesOrNo . ")"; if(mysqli_query($connect, $updateCognClassesQuery)) { echo $cognCourses[$count] . ' was updated for student ' . $studentID . "'s history.
\n"; } else { echo $cognCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } } function update_history($studentID, $coreCourses, $electCourses, $cognCourses, $connect) { $yesOrNo = 2; $semesterCore = ""; //update core class history for this student for($count = 0; $count < sizeof($coreCourses); $count++) { $takenCore = $_POST['takenCore' . $count]; if(isset($takenCore) && $takenCore === "Yes") { $yesOrNo = 1; } else { $yesOrNo = 0; } if($_POST['coreCourse' . $count . 'Semester'] === 'Spring' || $_POST['coreCourse' . $count . 'Semester'] === 'Summer' || $_POST['coreCourse' . $count . 'Semester'] === 'Fall' || $_POST['coreCourse' . $count . 'Semester'] === 'Winter' && isset($_POST['coreCourse' . $count . 'Semester'])) { $semesterCore = $_POST['coreCourse' . $count . 'Semester']; } else { $semesterCore = 'N/A'; } $updateCoreClassesQuery = "UPDATE CoreHistory SET semester = '" . $semesterCore . "', completed = " . $yesOrNo . " WHERE studentID = " . $studentID . " AND courseID = '" . $coreCourses[$count] . "'"; if(mysqli_query($connect, $updateCoreClassesQuery)) { echo $coreCourses[$count] . ' was updated for student ' . $studentID . "'s history.
\n"; } else { echo $coreCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } //update elective class history for this student for($count = 0; $count < sizeof($electCourses); $count++) { $takenElect = $_POST['takenElect' . $count]; if($takenElect === "Yes") { $yesOrNo = 1; } else { $yesOrNo = 0; } if($_POST['electCourse' . $count . 'Semester'] === 'Spring' || $_POST['electCourse' . $count . 'Semester'] === 'Summer' || $_POST['electCourse' . $count . 'Semester'] === 'Fall' || $_POST['electCourse' . $count . 'Semester'] === 'Winter' && isset($_POST['electCourse' . $count . 'Semester'])) { $semesterElect = $_POST['electCourse' . $count . 'Semester']; } else { $semesterElect = 'N/A'; } $updateElectClassesQuery = "UPDATE ElectiveHistory SET semester = '" . $semesterElect . "', completed = " . $yesOrNo . " WHERE studentID = " . $studentID . " AND courseID = '" . $electCourses[$count] . "'"; if(mysqli_query($connect, $updateElectClassesQuery)) { echo $electCourses[$count] . ' was updated for student ' . $studentID . "'s history.
\n"; } else { echo $electCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } //update cognate classes for this student for($count = 0; $count < sizeof($cognCourses); $count++) { $takenCogn = $_POST['takenCogn' . $count]; if($takenCogn === "Yes") { $yesOrNo = 1; } else { $yesOrNo = 0; } if($_POST['cognCourse' . $count . 'Semester'] === 'Spring' || $_POST['cognCourse' . $count . 'Semester'] === 'Summer' || $_POST['cognCourse' . $count . 'Semester'] === 'Fall' || $_POST['cognCourse' . $count . 'Semester'] === 'Winter' && isset($_POST['cognCourse' . $count . 'Semester'])) { $semesterCogn = $_POST['cognCourse' . $count . 'Semester']; } else { $semesterCogn = 'N/A'; } $updateCognClassesQuery = "UPDATE CognateHistory SET semester = '" . $semesterCogn . "', completed = " . $yesOrNo . " WHERE studentID = " . $studentID . " AND courseID = '" . $cognCourses[$count] . "'"; if(mysqli_query($connect, $updateCognClassesQuery)) { echo $cognCourses[$count] . ' was updated for student ' . $studentID . "'s history.
\n"; } else { echo $cognCourses[$count] . ' was not updated for student ' . $studentID . "'s history.
\n"; } } } if(isset($_POST['studentID']) && isset($_POST['coreCourses']) && isset($_POST['electCourses']) && isset($_POST['cognCourses']) && $_POST['update'] === "create") { create_history($studentID, $coreCourses, $electCourses, $cognCourses, $connect); } else if(isset($_POST['studentID']) && isset($_POST['coreCourses']) && isset($_POST['electCourses']) && isset($_POST['cognCourses']) && $_POST['update'] === "update") { update_history($studentID, $coreCourses, $electCourses, $cognCourses, $connect); } else { echo 'Something is not set.'; } ?>