rreynolds24
09-12-2008, 12:56 PM
I am trying to display a list of students, their subjects, and some data for each subject. It kinda works, except it repeats the pupils name for each subject:
http://www.peninsulafm.com/atts.JPG
I want it to show the pupils name just once in the left column, then, in the one row, show each of the students subjects, and corresponding data
(so it would look something like this)
http://www.peninsulafm.com/atts2.JPG
Here is my query from the database:
Query="SELECT pupils.PupilID, pupils.Surname, pupils.Forename, pupils.Form, subjects.subjectName, reports.attitud, pupils.attcomment"
Query=Query & " FROM (subjects RIGHT JOIN sets ON subjects.subjectID = sets.setsubject) RIGHT JOIN (pupils LEFT JOIN reports ON pupils.PupilID = reports.pupilID) ON sets.setid = reports.setID"
Query=Query & " WHERE form like '%" & request("form") &"%'"
Query=Query & " ORDER by surname"
and here is the table code
<TABLE border="1" cellspacing="1" style="border-collapse: collapse" width="50%">
<TR><font size="2">
<TD width="10%" align="center"><b>Pupil</b></TD>
<TD width="5%"><b>Subjects</b></TD>
<TD width="3%"><b>Attitudinals</b></TD>
<TD width="25"><b>Attitudinal Comment</b></td>
</font></TR>
<%
Do While Not RSlist.EOF
%>
<TR>
<TD width="15%" valign="top">
<%=RSlist("Forename")%> <%=RSlist("Surname")%><br>
<%=RSlist("Form")%></TD>
<TD width="5%" valign="top">
<% ' Needed is some code to iterate and display each subject without showing the name again
response.write(RSlist("subjectname") & "<br />")
%>
</TD>
<TD width="3%" valign="top" align="center">
<%
' write the attitudinal and a line break
response.Write(RSlist("attitud") & "<br />")
%>
</TD>
<TD width="25%" valign="top"><%=RSlist("attcomment")%> </TD>
</TR>
<%
RSlist.Movenext
Loop
%>
</TABLE>
I know I need to somehow do a count of how many subjects per student and then iterate through that, but I dont really know how to go about it.
Sorry for the long post, but if anyone can help me please it would be much appreciated. Thanks :)
http://www.peninsulafm.com/atts.JPG
I want it to show the pupils name just once in the left column, then, in the one row, show each of the students subjects, and corresponding data
(so it would look something like this)
http://www.peninsulafm.com/atts2.JPG
Here is my query from the database:
Query="SELECT pupils.PupilID, pupils.Surname, pupils.Forename, pupils.Form, subjects.subjectName, reports.attitud, pupils.attcomment"
Query=Query & " FROM (subjects RIGHT JOIN sets ON subjects.subjectID = sets.setsubject) RIGHT JOIN (pupils LEFT JOIN reports ON pupils.PupilID = reports.pupilID) ON sets.setid = reports.setID"
Query=Query & " WHERE form like '%" & request("form") &"%'"
Query=Query & " ORDER by surname"
and here is the table code
<TABLE border="1" cellspacing="1" style="border-collapse: collapse" width="50%">
<TR><font size="2">
<TD width="10%" align="center"><b>Pupil</b></TD>
<TD width="5%"><b>Subjects</b></TD>
<TD width="3%"><b>Attitudinals</b></TD>
<TD width="25"><b>Attitudinal Comment</b></td>
</font></TR>
<%
Do While Not RSlist.EOF
%>
<TR>
<TD width="15%" valign="top">
<%=RSlist("Forename")%> <%=RSlist("Surname")%><br>
<%=RSlist("Form")%></TD>
<TD width="5%" valign="top">
<% ' Needed is some code to iterate and display each subject without showing the name again
response.write(RSlist("subjectname") & "<br />")
%>
</TD>
<TD width="3%" valign="top" align="center">
<%
' write the attitudinal and a line break
response.Write(RSlist("attitud") & "<br />")
%>
</TD>
<TD width="25%" valign="top"><%=RSlist("attcomment")%> </TD>
</TR>
<%
RSlist.Movenext
Loop
%>
</TABLE>
I know I need to somehow do a count of how many subjects per student and then iterate through that, but I dont really know how to go about it.
Sorry for the long post, but if anyone can help me please it would be much appreciated. Thanks :)