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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text formatting

Status
Not open for further replies.

ITGL72

MIS
Jul 2, 2001
105
0
0
US

I'm using an online form to submit to a table I will use to hold news. The news will then be displayed on a front page of a website. Its a simple table, ID, SUBJECT, CONTENT, SUBMITBY fields and that's pretty much it. The form where a user enters the news has a TEXTAREA where they submit the content. Its all going into a SQL7 DB.

here's my dilemma, how can I display the CONTENT field on the screen once its queried to look like it was entered in the TEXT AREA like paragraphs, carriage returns, etc? Right now the text all comes on screen in one huge paragraph. I may actually put some pretty large pieces of news, even articles in this DB to be displayed on this screen so if I can get it to display in the format it was entered I think I would be in good shape.

Any suggestions? Something I have to change in the TEXTAREA line? The DATATYPE on the DB, or how its splashed on the SCREEN on the template that queries then displays?

Thanks!


PS: SQL server guys, what DATATYPE do you recommend for a field that would hold content like what I am mentioning above? Right now I just set it to VARCHAR and 4000.




 
Hi ITGL,

I can't help you with the Datatype (Although that sounds like the one I would use as well) but for the formatting I usually just put the output between <pre> </pre> tags. This does most of the formatting correctly. If it doesn't you can search on this forum for &quot;Text Formatting&quot; and I'm sure GunJack answered this question in more detail (Last Year sometime) by replacing carriage return and linefeed characters with there HTML equivilent.

Have fun...
 
ITGL,

Regular expressions work really well on manipulating text. Try using these before you print out your textfield.

<!---Replace Carriage Returns with paragraph tag--->
#REReplace(TextField, CHR(13), &quot;<p>&quot;, &quot;ALL&quot;)#

<!---Replace LineFeeds with line break tag--->
#REReplace(TextField,CHR(10),&quot;<br>&quot;,&quot;ALL&quot;)#

As for the datatype, I use that same type for news stories. It gets you about 2/3 of a page of text. If you have longer stories, try writing them to a text file and <cfinclude> them in. there are many of ways to do this. this is just one.

hope that helps,
jgroove
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top