Solved

Alphabetical List

Posted on 2012-04-02
5
341 Views
Last Modified: 2012-04-02
I have a query and I want to increment each record similar to the #currentrow# function, how can this be accomplished inside the query when the end of the records is not known. The list will not be over 26 letters.

EXample:

query

A
B
C

end query
0
Comment
Question by:-Matthew-
  • 3
5 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 37797154
I don't quite understand the question. Can you post an example of the query data .. and what the desired results look like?
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 37797241
Is this what you were asking?

This shows how to access a query's column value directly by the column name and the record number..


<cfloop index="row" from="1" to="#myQuery.recordCount#">

    mQuery["ColumnName"][row]
 
</cfloop>
0
 

Author Comment

by:-Matthew-
ID: 37797266
I want incrementAlphabet to just do that....go to A, B, C, D...

 
<cfquery name="agenda" datasource="source">
SELECT *
from sometable
</cfquery>

 <cfoutput query="agenda"> 

#incrementAlphabet#. #agenda.agenditem#

</cfoutput>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 37797297
Hmm... are you asking how to loop through the query columns dynamically? If that's what you mean, you could adapt gd's example like so

<cfoutput query="yourQuery">
     <!--- you can also use your own list of columns instead --->
     <cfloop list="#yourQuery.columnList#" index="colName">
            #yourQuery[ colName ][ yourQuery.currentRow ]#
       </cfloop>
       <br>
</cfoutput>
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 37797306
Oops, our posts crossed.

Assuming the query never contains more than 26 rows, something like this:

<!--- ascii 65 == uppercase A --->
<cfset startLetter = 65>
<cfoutput query="agenda">
     #chr(startletter)#. #agenda.agenditem#
     <cfset startletter = startletter + 1>
</cfoutput>
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question