Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    numbering ASP results

    I would like my results to be numbered numerically from 0 till infinity

    For Example if my database contained:

    Bob Jones
    Fred Jones
    Billy Jones


    It would display:

    0 Bob Jones
    1 Fred Jones
    2 Billy Jones

    I have my database on autonumber, but the numbers get messed up with we delete records.

  • #2
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    There is a way to code it that the numbers do show the you want them.
    I for the life of me can't find that damn code on my PC.
    When I do will post it.

    But yes that is possible to renumber it the way you want it.

    Otherwise in the mean time, why not make another field called sort and sort by that field instead: start with 0 to how many you need.

    Cheers
    Thanks for you support!

  • #3
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts
    make an array,

    Code:
    <% 
    dim numbering
    numbering = 0
    
    do while not RS.eof
    
    ''''''''write the number and you DB value
    
    response.write(numbering), response.write(RS("FieldName"))
    
    ''''''''increment the variable numnering by 1 and then loop it back to the beginning
    
    numbering = numbering + 1
    
    
    loop
    %>
    not sure if the loop will work but im sure you get the drift
    Last edited by Baleric; 04-17-2007 at 06:24 AM.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You don't have to do anything with arrays, just increment a counter

    Code:
    While Not rs.EOF
     Response.Write Counter & ": " & rs("field") & "<br>"
     Counter = Counter+1
     rs.MoveNext
    Wend

  • #5
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thats what i meant :P my bad


  •  

    Posting Permissions

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