I have a query that returns the top 25 records of one field of my database table. <cfquery name="top" datasource="mydatasource"> SELECT TOP 25 RATING, CATEGORY FROM MYTABLE ORDER BY RATING </cfquery> Code (markup): I'm not sure if this is the exact coding I use, but whatever... I want to be able to have the results listed to have a list number before them (i.e. 1, 2, 3, 4, 5,...) so the user can see what ranking each CATEGORY has. So, I simply need to create a column that just numbers the results. Do I need to use the "count" function to determine the number of results, then do some sort of incremental numbering? I mean, I already know I will only have 25...
when you output them just use #currentrow# where you want the numbers.. i.e. <cfoutput query="top"> <tr> <td>#currentrow#</td> <td>#category#</td> </tr> </cfoutput> Code (markup): by the way i am not advocating the use of tables in this situation. however.. if this is just going to be a standard list <ol> <cfoutput query="top"> <li>#category#</li> </cfoutput> </ol> Code (markup): these are both assuming the ratings will always be in the set from 1 to 25
Great, thank you. So #currentrow# is a standard CF function that will always work? Or, do I need to define it somehow, say, in my query?
query_name.currentRow The current row of the query being processed by cfoutput. http://livedocs.adobe.com/coldfusion/6.1/htmldocs/main_a10.htm ... because you are in this tag: <cfoutput query="top"> you can simply use #currentRow#