CourseCreditsSemesterTaken Prior Degree"; //checking that the queries are valid if(!mysqli_query($connect,$queryCurrDegreeElect) && mysqli_query($connect,$queryCurrDegreeElect) != NULL) { printf("Error with first query: %s\n", mysqli_error($connect)); exit(); //if valid queries, do the good stuff } else { //allows variables to be used out of scope global $currElectCourses; $currElectCourses = mysqli_fetch_all($currentElectClasses,MYSQLI_ASSOC); //while there are Elect classes to add for($count = 0; $count < sizeof($currElectCourses); $count++) { //gets the credits associated with that class $queryCredits = "SELECT credits FROM Courses WHERE courseID = '" . $currElectCourses[$count]['courseID'] . "'"; $creditsResult = mysqli_query($connect, $queryCredits); $credits = mysqli_fetch_array($creditsResult,MYSQLI_ASSOC); //checking if the course was part of the degree they completed //if so, the box will be prefilled with yes, no otherwise $takenElectQuery = "SELECT completed FROM ElectiveHistory WHERE studentID = " . $studentID . " AND courseID = '" . $currElectCourses[$count]['courseID'] . "'"; $takenElectResult = mysqli_query($connect, $takenElectQuery); $takenElect = mysqli_fetch_array($takenElectResult,MYSQLI_ASSOC); $semesterElectQuery = "SELECT semester FROM ElectiveHistory WHERE studentID = " . $studentID . " AND courseID = '" . $currElectCourses[$count]['courseID'] . "'"; $semesterElectResult = mysqli_query($connect, $semesterElectQuery); $semesterElect = mysqli_fetch_array($semesterElectResult,MYSQLI_ASSOC); echo "" . $currElectCourses[$count]['courseID'] . "\n" . "" . $credits['credits'] . "\n". ""; //start of semester echo "\n"; //end of semester echo "\n" . "\n"; } echo "\n"; } } ?>