you are still showing a separate table for each different type of user and you have usernames stored in related tables, rather than using the user's id.
you were told two or three threads ago not to have separate tables for same meaning information (the users) and you have since gotten your login code to work with a 'type' field in your user table.
since you have posted old/out of date table definitions, you need to rework those before you can write any code to use that data.
anyway, to answer your question -
when a logged in lecturer navigates to the attendance page, you would use their user id to retrieve their list of subjects/classes. when they click on one of them, you would use the class id to retrieve the list of students in that class.Go to the full post