|
|||||||
| ASP Discussion and technical support for using and deploying Active Server Pages. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help with loops
I am modifying someone else's code without much luck. I need code to pull semesters and college courses from our database. The result should look like:
Courses Spring 06 MGMT 345 MGMT 560 Summer 06 MGMT 450 If MGMT 345 has more than one section, the results should only show one MGMT 345 If instructor is not teaching during semester the semester should not show If no courses are being taught, courses should not show either Currently the loop is not displaying all the courses for spring and still displaying Spring if no courses present for that semester and there are courses for summer. CODE IS: <% fac=rs("faculttyid") sql1="SELECT subcourse.subcourse, subcourse.courseid, subcourse.subcourseid, " sql1= sql1 & "section.semesterid, section.facultyid, section.subcourseid, semester.semester, semester.active " sql1= sql1 & "FROM subcourse, section, semester " sql1= sql1 & "WHERE subcourse.subcourseid=section.subcourseid AND semester.semesterid=section.semesterid AND " sql1= sql1 & "facultyid='" & ids & "' AND (semester.semesterid=5 OR semester.semesterid=6) " sql1= sql1 & "ORDER BY semester, subcourse " Set rs1 = Server.CreateObject("ADODB.Recordset") rs1.Open sql1, DatabaseConnection if rs1.EOF then else%> <%On Error Resume Next rs1.MoveFirst sem=rs1("semester") sem1=0%> <tr><td><div align="center"><strong>Courses<br> <%do while Not (rs1.eof)%> <%if sem <> sem1 and sem1 = "0" then sem1=sem%> <%=sem%></strong></div></td></tr> <%dim prevcourseid precourseid=0 %> <%if rs1("courseid")<>prevcourseid then %> <tr><td> <a href = "http://users.cba.siu.edu/<%=rs("userdirID")%>/<%=rs1("courseid")%>/"> <%=rs1("subcourse")%></a></td></tr> <%prevcourseid=rs1("courseid") end if%> <%elseif sem = sem1 and sem1 <> "0" then%> <% else sem1=sem %> <tr><td><div align="center"><strong><%=sem%></strong></div></td></tr> <%if rs1("courseid")<>prevcourseid then %> <tr><td> <a href = "http://users.cba.siu.edu/<%=rs("userdirID")%>/<%=rs1("courseid")%>/"> <%=rs1("subcourse")%></a></td></tr> <%prevcourseid=rs1("courseid") end if%> <% end if rs1.MoveNext sem=rs1("semester") loop %> <% rs1.close Set rs1 = Nothing end if %> |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|