Hi ok I have a table: "rlbTerms" that contains basically a list of terms and their definitions.
I create a page with a query that returns all the terms and definitions in a table layout and are order by terms ASC.

What I want is a way to create anchor tags dynamically so that a user can click on the letter "G" and it will take them to the "G" section of the table.

I tried googling the function, but honestly not sure what to look for. I hope I explained this well enough to understand. Thanks for any advice in advance!

btw here is my query:

<cfquery name="rsTerms" datasource="rlbulbs">
SELECT rlbterms.terms, rlbterms.definitions
FROM rlbterms
ORDER BY rlbterms.terms
</cfquery>

Here was what I was trying to do:

<cfquery name="rsTerms" datasource="rlbulbs">
SELECT rlbterms.terms, rlbterms.definitions, left(rlbterms.terms,1) AS letterField
FROM rlbterms
ORDER BY rlbterms.terms
</cfquery>

I think this is really more of a cold fusion question than sql (and I haven't used cold fusion in over ten years so I can't answer). Usually you would do this on the scripting layer rather than the Db layer.

As you loop through the results you build a string of the first letters as you build the output, adding in the anchors as you go. Then you output the letter based index string first followed by the full detailed results string.

Hi Brillig thanks for the reply. No actually it is a SQL question. The LEFT() function is a SQL string function. Anyway, I almost have it working! lol

The issue I am having now is probably more a CF issue. Not sure whether to mark this solved yet or not though

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.