Forum Moderators: open

Message Too Old, No Replies

create a link to go back to another page

         

aweise

7:38 pm on May 28, 2003 (gmt 0)

10+ Year Member



I have a view page that results from a query that will spawn either a view or enroll page. I want the view page to also link to enroll if the enrollment count is less than maxenroll. So users can view the class roster if the class is full or if there's openings. If there's openings there should be a link to enroll for that class.

I'm still in my learning stages so I'm sure what I have is simple to figure out but I can't seem to. When I try to use an if statement during the loop my response comes back however many entries I have. For example: two enrollees brings back two responses, or more if the class is already full. It should only bring a response to enroll if there are openings.

Here's my code:

<%
response.write "<tr><td class=head>Branch/Department</td><td></td><td class=head>Name</td><td></td><td class=head>Title</td><td></td><td class=head>Ext</td></tr>"
%>



<% DO WHILE NOT rstemp.eof
classdate=rstemp("classDate")

' put fields into variables
' enrollid=rstemp("enrollID")
classid=rstemp("classID")
name=rstemp("name")
ext=rstemp("ext")
dept=rstemp("dept")
title=rstemp("title")
enrolled=rstemp("enrolled")
if not isNumeric(enrolled) then enrolled = 0
maxenroll=rstemp("maxEnroll")
openslots = maxenroll - enrolled
'if enrolled < maxenroll then response.write "test"
' write the fields to browser
response.write "<tr class=view><td width=180> "& rstemp("dept") & "</td><td width=10> </td><td width=170> "& rstemp("name") & "</td><td width=10> </td><td width=120>"& rstemp("title") & "</td><td width=10> </td><td width=100>"& rstemp("ext") & "</td></tr>"

rstemp.movenext
LOOP

%>

<TR>
<TD> </td>

<td>

<% if enrolled < maxenroll then %>
<a href="enroll.asp?classID=<%=rstemp("classID")%>&className=<%=Escape(classname)%>&classDate=<%=classdate%>">
Enroll</a>
<% else %>
Go back to Training
<% end if %>


</td>
</TR>

liwei

5:12 am on May 30, 2003 (gmt 0)

10+ Year Member



I don't know if I really know what you meant.

here are the modified code:

<%
response.write "<tr><td class=head>Branch/Department</td><td></td><td class=head>Name</td><td></td><td class=head>Title</td><td></td><td class=head>Ext</td></tr>"
%>

<% DO WHILE NOT rstemp.eof
classdate=rstemp("classDate")

' put fields into variables
' enrollid=rstemp("enrollID")
classid=rstemp("classID")
name=rstemp("name")
ext=rstemp("ext")
dept=rstemp("dept")
title=rstemp("title")
enrolled=rstemp("enrolled")
if not isNumeric(enrolled) then enrolled = 0
maxenroll=rstemp("maxEnroll")
openslots = maxenroll - enrolled
if enrolled < maxenroll then
%>
<tr class=view>
<td width=180> <%= rstemp("dept")%> <a href="enroll.asp?classID=<%=rstemp("classID")%>&className=<%=Escape(classname)%>&classDate=<%=classdate%>">
Enroll</a>
</td>
<td width=10> </td>
<td width=170> <%=rstemp("name") %></td>
<td width=10> </td>
<td width=120><%= rstemp("title")%></td>
<td width=10> </td>
<td width=100><%=rstemp("ext")%></td>
</tr>

<%else%>
<tr class=view>
<td width=180> <%= rstemp("dept")%></td>
<td width=10> </td>
<td width=170> <%=rstemp("name") %></td>
<td width=10> </td>
<td width=120><%= rstemp("title")%></td>
<td width=10> </td>
<td width=100><%=rstemp("ext")%></td>
</tr>
<%
end if
rstemp.movenext
LOOP

%>