Solved

Cold fusion Alphabetical listing

Posted on 2012-04-10
3
303 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 175 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

740 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