Below is my query which works fine:
$query = "
SELECT st.CourseId, c.CourseName, st.Year, st.StudentUsername, st.StudentForename, st.StudentSurname,
s.ModuleId, m.ModuleName, m.Credits, s.SessionId, s.SessionWeight, gr.Mark, gr.Grade
FROM Course c
INNER JOIN Student st ON c.CourseId = st.CourseId
JOIN Grade_Report gr ON st.StudentId = gr.StudentId
JOIN Session s ON gr.SessionId = s.SessionId
JOIN Module m ON s.ModuleId = m.ModuleId
WHERE
(st.StudentUsername = '".mysql_real_escape_string($studentid)."')
";
Below is my results outputted by using php:
Course: INFO101 - Bsc Information Communication Technology Year: 3
Student: Mayur Patel (u0867587)
Module: CHI2550 - Modern Database Applications
Session: AAB 72 (A)
Course: INFO101 - Bsc Information Communication Technology Year: 3
Student: Mayur Patel (u0867587)
Module: CHI2513 - Systems Strategy
Session: AAD 61 (B)
Course: INFO101 - Bsc Information Communication Technology Year: 3
Student: Mayur Patel (u0867587)
Module: CHI2550 - Modern Database Applications
Session: AAE 67 (B)
How do I display it using php so that it only shows Course details and Student details only once, it will show each module in the course only once and shows each session being below each module it belongs to:
The output from above should look like this in other words:
Course: INFO101 - Bsc Information Communication Technology Year: 3
Student: Mayur Patel (u0867587)
Module: CHI2550 - Modern Database Applications
Session: AAB 72 (A)
Session: AAE 67 (B)
Module: CHI2513 - Systems Strategy
Session: AAD 61 (B)
PHP code to output the results:
$output1 = "";
while ($row = mysql_fetch_array($result)) { //$result is the query
$output1 .= "
<p><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <strong>Year:</strong> {$row['Year']}<br/>
<strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})
</p>";
$output1 .= "
<p><strong>Module:</strong> {$row['ModuleId']} - {$row['ModuleName']} <br/>
<strong>Session:</strong> {$row['SessionId']} {$row['Mark']} ({$row['Grade']})
</p>";
}
echo $output1;
Thank You