Skip to main content
Inspiring
May 10, 2010
Question

Help - Cannot Remember how to do this !

  • May 10, 2010
  • 2 replies
  • 574 views

I have a string data separated by a comma : xxx,aaa,bbb,ccc,ddd,eee,yyy,   etc..... stored in sql table.

What is the command/technique to break up this string and display this data one on top of another :

xxx

aaa

bbb

ccc

ddd

eee

yyy

I remember doing it before but cannot remember how to do it and dont know what it is called to research.

Thanks

This topic has been closed for replies.

2 replies

Inspiring
May 10, 2010

I have a string data separated by a comma :

xxx,aaa,bbb,ccc,ddd,eee,yyy,   etc..... stored in sql

table.

You should seriously consider normalizing your table. Storing comma separated lists is bad for performance, data integrity and manageability.

 

What is the command/technique to break up this string and

display this data one on top of another :

But to answer you question, use a cfloop with the "list" attribute. Then cfoutput each value followed by a line break (ie BR).

trojnfnAuthor
Inspiring
May 10, 2010

I found some old code using cfloop index and list, seems to work :

<cfloop index = "i" list = "#carrierTracking#">
<cfoutput>
<cfinput type="text" name="carrierTracking" value="#i#">
</cfoutput>
<br>
</cfloop>

Now in my haste, I discoverd that this field originally was a textarea. When it is displayed, it just uses <cfoutput>#textareaName#</cfouput> so that the textarex box is eliminated. However, this is where the problem exists. One of the lines/sentence is aaa,bbb,ccc,ddd,eee,fff,.......etc, and without the textarea, this line continues to the right, throwing the screen out of whack.

If I display it as a textarea, I think that would solve the problem. But is there anyway to do it without the textarea ? I dont want to display the lines.

Thanks

Inspiring
May 10, 2010

I suppose one might look at this and think you need to REPLACE the commas with something that represents a line break in HTML.

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6a3a.html

http://www.w3schools.com/tags/

--

Adam