I made a table allstudentsAnswers20BE. When a student clicks “Submit” on the homework page, PHP immediately checks the student’s answers against the answers in the table correctAnswers20BE, according to the column weeknr. (Each week there are, of course, different answers.) PHP increments $score for a correct answer.
Each student’s answers and their name, number, week number and score are written to the table allstudentsAnswers20BE.
I want to extract the columns: name, number, score for any given week number.
For example:
SELECT name, number, score FROM allstudentsAnswers20BE WHERE weeknr = 'Week9';
will get me what I want, but:
Within the time limit for each homework, a student may send the homework more than 1 time. Therefore, a student may have more than 1 score. (Some send 4 or 5 times)
I want to get only the row with the highest score. (Not to be too harsh.)
Should I read everything into an array and then somehow eliminate the lower scores for each student number?
Or can this be done directly within the SELECT query??