Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

waqasraza123's avatar

save multiple inputs in middle table with same name

I am allowing users to add multiple subjects on the fly while adding a student, for example when you are adding a student you can add a subject i.e Math then you will set its attributes teacher name, credit hours etc. But when saving to db I need to save the information to my middle table students_subjects

id | student_id | subject_id | teacher_name | credit_hours

user can add multiple fields like this

The problem is that how I can save the information for each subject. I can save the subject_id in a hidden field and get that but how would I know that this id is related to that particular subject and get the teacher and credit hours for that id.

0 likes
0 replies

Please or to participate in this conversation.