Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to break up db field when outputing 1

Status
Not open for further replies.

dugen

Programmer
Jun 16, 2003
59
US
Hi,

I have a group of checkboxes that go into my database as an array.

When i output the data it appears like this:
monday,tuesday,wednesday,thursday etc....

I would like to replace all of the commas with line breaks so it appears like this:

monday
tuesday
wednesday
etc...

I know i have to put some code around my output statement but i dont know how to do this.

<cfoutput>#getEntrantDetail.times#</cfoutput>


Thanks for the help
 
<cfoutput>#replace(getEntrantDetail.times,",","<br>")#</cfoutput>

BTW it's not an array. It's a comma-delimited list or, more accurately, a character string. Storing such a construct in a field is not recommended data design. It's not, well, normal.


Phil H.
-----------
A virtual machine ate my accounting data. I transferred it to a physical box, then I beat it to smithereens with a sledgehammer. I feel better.
 
Phil is correct. Storing data using a comma delimited list in a single field violates the DB rule of atomicity. You should use some kind of matrix table instead to keep track of multiple relationships like this.

If you are going to use a comma delimited list, and I do it from time to time, you will find searches to be MUCH easier if you put leading and ending commas in the list when you insert it.

For example:

,pig,dog,rat,snake,

instead of

pig,dog,rat,snake

that way you can search for ,dog, and not have to worry about also picking up part of doggy or dogbert or whatever.

Cheers,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top