Results 1 to 2 of 2

Thread: asp help

  1. #1
    Join Date
    May 2004
    Posts
    28

    asp help

    I need some help writing an IF statement for ASP. Perhaps an IF statement isn't the best choice here, I'm not really sure. Basically I am outputting a list of dealers for our website. Due to the design of the page, I need to change the table column properties in the last record so that it is different from the rows above it. Here's the code I have so far. I can't seem to get this to work though. It will output everything except the last record. How do I create a conditional output like this? Is an IF statement even the correct approach here?

    Code:
    <%
    SQL_query = "SELECT * FROM dealerpage WHERE Region = 'North America' "
    Set RS = MyConn.Execute(SQL_query)
    
    IF NOT RS.EOF THEN
    Response.Write "<tr><td><p align='left'><a href=' " & Rs("PageURL") & " '><b>" & rs("Country") & "</b></a></p></td></tr>"
    RS.MoveNext
    ELSE
    Response.Write "<tr><td class='last'><p align='left'><a href=' " & Rs("PageURL") & " '><b>" & rs("Country") & "</b></a></p></td></tr>"
    RS.MoveNext
    END IF					
    
    %>

  2. #2
    Join Date
    Jan 2006
    Location
    Manchester England UK
    Posts
    225
    The problem with your code is that it will never fire the else if it is part of a loop.

    The way I thought you could do this is to know how many records there are and then when you get the last record write out the alternate line.

    something along the lines of :

    Code:
    intCurrentRecord = 1
    while not rs.eof
        If intCurrentRecord = intRecordCount then
             ' this is the last record
        else
    
        end if
        intCurrentRecord = intCurrentRecord + 1
        rs.movenext
    wend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •