i am creating a assessment system in which students can add subjects for enrollment but my problem is i want to make it that the system wont allow the student to take that subject if they have not taken the required subject before that.. for example a student want to take the subject physics 2 but before he ca开发者_JAVA技巧n take it he should first finish physics 1 how can i make that if he tries to take the subject physics 2 without finishing the physics 1 the system wont allow him to list the subject physics 2. can you please help me? and by the way i am using MySQL and PHP here.. thx guys..
At the very beginning: without anything to answer, there's no point in trying to find a valid answer. Please post a part or an example of the code you're talking about!
-- Just theory, don't know if this apply to you. --
First, let assume you initialize a class #student as $student. In $student, there's an array of the students' subjects, lets call them s[k]. This example shows the verification if physics 1 has been issued to the student and is currently set true - hence the student is able to attend physics 2.
$p2_permitted = ( isset($student->subjects["p1"]) && $student->subjects["p1"] == true ) ? true : false;
if ( $p2_permitted ) $student->subject["p2"] = true;
I guess you're loading the data from the db? So this would be like: load, parse + verify (is physics 2 permitted to be issued to student k?), modify + extend ( if the existence of physics 1 in the school-career of the student k permits the issueing of the "physics 2"-flag, let's do that), save (push back into the db).
精彩评论