Solved

Alphabetical List

Posted on 2012-04-02
5
346 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-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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