I have searched, but can't seem to find how I do this. Basically I have two tables, and if this was slightly less complicated a simple join would work.
What I am trying to achieve is that each pupil chooses two subjects, and he scores a certain amount of points for each subject per week. Then I want to be able to display the pupil's name, his subject 1, then the score, then subject 2 and the score. With the query below, this obviously works for showing the score in subject 1, but I'm baffled as how to get subject 2.
$query = "SELECT pupils.name, pupils.subject1, pupils.subject2, subjects.week1 + week2 + week3 AS subject1points
FROM pupils, subjects
WHERE pupils.subject1 = subjects.subject";
$result = @mysql_query ($query);
if ($result) {
echo....
Maybe some sort of subquery? Thanks in advance. Then of course I'm finishing off the table and displaying the results.