I have a database that has id, names,subject and totalMarks. Each row includes a student's id, name, Subjects, and thier total marks which means that there are multiple rows for each student. That's not my problem. My problem is that students have more than one subject with total marks listed...which means there are two separate rows for 1 student , one for each subject. So bad for me I have less control over the formatting of the data since it's exported from a system that doesn't have a lot of formatting options.

Below is an example of how the system looks like

```
id   stdID      name    subject     totalMarks
1    BA53       Smith    Maths          100%
2    BA45       Emma     Maths          87%
3    BA53       Smith    English        98%
4    BA45       Emma     English        78%

```

I would like to combine the rows with the same Student ID `stdID` and `subject` into one row using the `subject` column values as heading for the `total marks` attained by the student, Ideally the final result would look something like,

```
id   stdID      name     Maths          English
1    BA53       Smith    100%            98%
2    BA45       Emma     87%             78%

```

Is this possible using PHP and/or MySQL? I'm not looking for anyone to write the entire code or anything. I just can't seem to think of a way to accomplish it. I'd be happy with any direction/indication of a way to go about this.

As always, thanks for your time and help.