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!

New line in a memo field... 1

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
Let's say I have a database full of poems or songs. I have a table with a memo field to hold the lines to the poem, and want to query the DB and output the text. If the text is all one word after another, how can I output it with carriage returns in the proper places? Can I do something like put semi-colons in the memo field and tell coldfusion to give me a <BR> when it encounters a semi-colon? Obviously, I'm not sure what to do, but hopefully you all know what I'm getting at.

For example: If the text in the memo field is like so:
Code:
This is a poem; I know it is a really bad one; It doesn't even rhyme; I shouldn't quit my day job

How can I output it like this:
Code:
This is a poem;
I know it is a really bad one
It doesn't even rhyme
I shouldn't quit my day job

Clear as mud? Thanks in advance guys!
Kevin
slanek@ssd.fsi.com
 
Hey Kevin,

You can use the CF replace function like this:

<cfoutput>#replace(q1.Field1,&quot;;&quot;,&quot;<br>&quot;,&quot;all&quot;)#</cfoutput>

If your poems already have the proper line breaks in them, you can use the line feed character (ascii value 10) to trigger <br> tags like this:

<cfoutput>#replace(q1.Field1,#chr(10)#,&quot;<br>&quot;,&quot;all&quot;)#</cfoutput>

Let me know if you have any problems,
GJ
 
I've said it before, I'll say it again, you're the man. That's exactly what I was looking for.

Thanks!
Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top