edit student record

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trtcom1
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2008 10:51 am

edit student record

Post by trtcom1 »

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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: edit student record

Post by requinix »

Get rid of it. Yeah, that's right.

Remove the currentNumberOfStudents field. Then use a query to get that information:

Code: Select all

SELECT COUNT(*) FROM course_allocation WHERE courseID=$id
trtcom1
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2008 10:51 am

Re: edit student record

Post by trtcom1 »

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.
trtcom1
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2008 10:51 am

Re: edit student record

Post by trtcom1 »

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?
Post Reply