built mysql selector to select next class for the attend next class function