[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Cold fusion Alphabetical listing

Posted on 2012-04-10
3
Medium Priority
?
307 Views
Last Modified: 2012-06-27
I have a sql directory of names. I want to output an alphabetical listings that displays the alphabet A thru Z, but the letters that contain an actual directory name appear as links.
0
Comment
Question by:swaggrK
[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
  • 2
3 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 37830195
Do you mean a query containing directory names?

ie  DirectoryName
     Aaaaa xxxx
     Cxxxxx
     Dddddd
     .....
0
 

Author Comment

by:swaggrK
ID: 37830506
No.

I mean the following...

Table: tbl_names
Field 1: name_of_company
Field 2: name_of_company_id

Results:
Apple
Burger King
Zerox

Assuming that these are the only three company names in my table,
A, B, Z, would be the only linkable letters.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 700 total points
ID: 37830573
If I'm understanding correctly, you just want to display A-Z and creating make the letter a link only when one (or more) company records exist that start with that letter?

If so, you could run a query to get a unique list of the first letters of existing companies:
             
              <cfquery name="getLetters" ....>
               SELECT   LEFT(name_of_company, 1) AS FirstLetter, COUNT(*)
               FROM     table_names
               GROUP BY LEFT(name_of_company, 1)
             </cfquery>

Then put the results into a list

             <cfset linkableLetters = valueList( getLetters.FirstLetter )>

Then use a loop to generate the letters A - Z, checking #linkableLetters# to see when you should create a link

             <cfoutput>
             <!--- 65 - ascii for upper case "A" --->
             <cfloop from="65" to="90" index="n">
                   <cfset letter = chr( n )>
                   <cfif listFindNoCase(linkableLetters, letter)>
                           <a href="somePage.cfm?letter=#letter#">#letter#</a>            
                   <cfelse>
                           #letter#
                   </cfif>
             </cfloop>
             </cfoutput>

(Not tested, so watch out for typos)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

650 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