www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > ASP

    ASP Discussion and technical support for using and deploying Active Server Pages.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-03-2006, 03:35 PM
    Milou Milou is offline
    Registered User
     
    Join Date: May 2006
    Posts: 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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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
    %>
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:56 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.