Hi there,
I need help with a routine to edit a student and course (class) record.
I have defined on my database 3 tables: student,course (class) and course_allocation.
student has the following fields:
studentNum
firstName
lastName
course has the following fields:
courseID
courseName
currentNumberofStudents
course_allocation has the following fields:
studentNum
courseID
When I edit a student record, as it is it edits the records on student and course_allocation tables.
Suppose if for some reason I need to change/move the student from class 101 (maths) to class 102 (physics).
I want to write a routine that updates the currentNumberofStudents field on the course table as well, besides the student and course_allocation tables.
Example if class 101 has currently 5 students registered and class 102 has 2 students registered for it and I update the records of one of the students and I move him to class 102, then the currentNumberofStudents field on the table course should show 4 students for class 101 and 3 students for class 102.
But I am unable to do it, suggestions on how can I do it?
edit student record
Moderator: General Moderators
Re: edit student record
Get rid of it. Yeah, that's right.
Remove the currentNumberOfStudents field. Then use a query to get that information:
Remove the currentNumberOfStudents field. Then use a query to get that information:
Code: Select all
SELECT COUNT(*) FROM course_allocation WHERE courseID=$idRe: edit student record
Thank you so much for the input.
However, the count for the course_allocation works fine.I am thinking about introducing a courseCapacity field on the course table to use it to limit as flag, when the class is full then you cannot add no more students.
However, the count for the course_allocation works fine.I am thinking about introducing a courseCapacity field on the course table to use it to limit as flag, when the class is full then you cannot add no more students.
Re: edit student record
Thank you so much for input.
However, the count for the course_allocation works fine.I am thinking about introducing a courseCapacity field on the course table to use it to limit as flag, when the class is full then you cannot add no more students.That is where my problem lies.I want some users to create a class and say this is the total number of students allowed, so then when you add and allocate students to a class when it reaches that number the system should tell you that the class is full.
I have hard-coded that number but I want it to read it from the database field.Any ideas?
However, the count for the course_allocation works fine.I am thinking about introducing a courseCapacity field on the course table to use it to limit as flag, when the class is full then you cannot add no more students.That is where my problem lies.I want some users to create a class and say this is the total number of students allowed, so then when you add and allocate students to a class when it reaches that number the system should tell you that the class is full.
I have hard-coded that number but I want it to read it from the database field.Any ideas?