Im after a bit more advice if possible... Im trying to tidy up some of my pages, and a couple of pages where I have 2 queries and data connections I am trying to combine them to one. So for example:
Code:
Query="SELECT PupilID, Surname, Forename, Form, attcomment, attcomment2, atttarget"
Query=Query&" FROM pupils"
Query=Query&" WHERE PupilID=" & request("pupilID")
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "S1"
Set RSlist = Server.CreateObject("ADODB.recordset")
RSlist.Open Query,DataConn,3
Query2="SELECT setID, attitud, pupilID FROM reports"
Query2=Query2 & " WHERE pupilID = " & request("pupilID")
Query2=Query2 & " ORDER by setID"
Set DataConn2 = Server.CreateObject("ADODB.Connection")
DataConn2.Open "S1"
Set RSlist2 = Server.CreateObject("ADODB.recordset")
RSlist2.Open Query2,DataConn2,3 I have changed to the below, with just one data conn (RSlist) Code:
Query="SELECT pupils.PupilID, pupils.Surname, pupils.Forename, pupils.attcomment, pupils.form, pupils.atttarget, pupils.attcomment2, reports.setID, reports.attitud"
Query=Query&" FROM pupils LEFT JOIN reports ON pupils.[PupilID] = reports.[pupilID]"
Query=Query&" WHERE pupils.[PupilID]=" & request("pupilID") The problem is that halfway the page Ive got a loop which moves on to the next record before its finished using data from the current record, and Im not sure how to fix it.
Code:
...
<TABLE border="1" cellspacing="1" style="border-collapse: collapse" width="50%">
<TR>
<TD width="10%" align="center"><b>Set</b></TD>
<TD width="7%" align="center"><b>Attitudinal</b></TD>
</TR>
<%
' While there are still more records
Do While Not RSlist2.EOF
%>
<TR>
<TD width="10%" align="center">
<%=RSlist2("setID")%> </TD>
</TD>
<TD width="7%" align="center">
<%
' write the attitudinal
response.Write(RSlist2("attitud"))
%>
</TD>
</TR>
<%
' move on to next record
RSlist2.Movenext
Loop
%>
</TABLE>
</body>
IT WORKS TO HERE THEN FAILS
<!-- form is opened here -->
<form method="POST" action="att3dupdate.asp">
<input type="hidden" name="form" value="<%=RSlist("form")%>">
<input type="hidden" name="pupilID" value="<%=request("pupilID")%>">
<h4><font color="#FF0000">As a result of these grades <%=RSlist("forename")%> : </font></h4>
<select name="attcomment">
<option>is commended for a high standard of effort</option>
<option>is commended for improved effort</option>
<option>maintains a reasonable standard of effort</option>
<option>will be put on Form Teacher's Report</option>
<option>will be put on Deputy Headmaster's Report</option>
<option>will be put on Headmaster's Report</option>
</select>
<!-- Display what has currently been saved -->
<p>Currently saved as: <font color="#000000"><%=RSList("attcomment")%></font>
<hr>
<h4><font color="#FF0000">Target for the next five weeks is to:</font></h4>
<!-- create targets comment parameter -->
<select name="atttarget">
<option>sustain or improve upon the above grades</option>
<option>eliminate all C grades from the report</option>
<option>upgrade 1 B grade to A</option>
<option>upgrade 2 B grades to A's</option>
<option>upgrade 3 B grades to A's</option>
<option>upgrade 4 B grades to A's</option>
<option>upgrade 5 B grades to A's</option>
</select>
<!-- Display what has currently been saved -->
<p>Currently saved as: <font color="#000000"><%=RSList("atttarget")%></font>
<hr>
<!-- create the optional comment parameter -->
<h4><font color="#FF0000">This box is for any other optional comments:</font></h4>
<textarea rows="2" name="attcomment2" cols="67"><%=RSlist("attcomment2")%></textarea>
... I tried expanding the loop to include the 2nd part of the page but that doesnt seem to work. Do I need to rethink the way the first table is drawn so that I can keep the data for the 2nd part of the page, before moving onto next record?