Solved

Alphabetical List

Posted on 2012-04-02
5
337 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now