Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Alphabetical List

Posted on 2012-04-02
5
Medium Priority
?
362 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

597 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