Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-12-2007, 11:28 PM   PM User | #1
rparish
New to the CF scene

 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
rparish is an unknown quantity at this point
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.
rparish is offline   Reply With Quote
Old 04-13-2007, 06:26 AM   PM User | #2
westmatrix99
Regular Coder

 
westmatrix99's Avatar
 
Join Date: Dec 2006
Location: South Africa
Posts: 307
Thanks: 12
Thanked 0 Times in 0 Posts
westmatrix99 is an unknown quantity at this point
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!
westmatrix99 is offline   Reply With Quote
Old 04-17-2007, 05:10 AM   PM User | #3
Baleric
Regular Coder

 
Baleric's Avatar
 
Join Date: Feb 2005
Location: Australia
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Baleric is an unknown quantity at this point
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 05:24 AM..
Baleric is offline   Reply With Quote
Old 04-18-2007, 01:52 PM   PM User | #4
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
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
degsy is offline   Reply With Quote
Old 04-19-2007, 04:04 AM   PM User | #5
Baleric
Regular Coder

 
Baleric's Avatar
 
Join Date: Feb 2005
Location: Australia
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Baleric is an unknown quantity at this point
thats what i meant :P my bad
Baleric is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09 AM.


Advertisement
Log in to turn off these ads.