SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HELP ME!! - Incrementing a value by 1 on each loop

    Hello,

    I've inherited some ASP code which I'm not entirely sure about (I'm a Cold Fusionneer for my sins), and was wondering if somebody could help me make a slight code alteration that is required?

    Basically, my code is :

    If Not(objRetrieve.BOF AND objRetrieve.EOF) Then
    Do While Not objRetrieve.EOF
    %>
    <%="&name"%><%=trim(objRetrieve("Players_ID"))%>=<%=trim(objRetrieve("Players_Name"))%>
    <%
    objRetrieve.Movenext
    Loop
    End If


    However, where I currently have <%=trim(objRetrieve("Players_ID"))%> I'd instead like to auto-increment that number each time. So on the first loop it would be 1, then 2, then 3, etc.

    I'm not sure how to do this in ASP. Can anybody advise what this code should be?

    All the best,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dim i
    i = 0

    If Not(objRetrieve.BOF AND objRetrieve.EOF) Then
    Do While Not objRetrieve.EOF
    i = i + 1
    %>
    <%="&name"%><%=i%>=<%=trim(objRetrieve("Players_Name"))%>
    <%
    objRetrieve.Movenext
    Loop
    End If

    This should do it..

    why so many <% %> though?

  3. #3
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi addstravel,

    That did the trick!!

    Thankyou - lots of <% %> as it was kind of hacked together. Have tidied it up now.

    Many thanks,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP


Bookmarks

Posting Permissions

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