Old 26-06-2007, 14:16   #1 (permalink)
SeanMedia
Senior Member
 
SeanMedia's Avatar
 
Join Date: Jun 2003
Location: Belfast, Ireland
Posts: 416
Send a message via MSN to SeanMedia Send a message via Skype™ to SeanMedia
simple question

I have built a CMS for a client and when they enter text into a <textarea> and it's saved into a database, I can't get it to include any new lines saved when I output the text onto a page between <p> tags.

Basically the user enters:
Code:
this is a paragraph

and it spits out:
Code:
this is a paragraph

How do I fix this?
  Reply With Quote
Old 26-06-2007, 14:37   #2 (permalink)
Jack000
I ride polar bears
 
Jack000's Avatar
 
Join Date: Oct 2006
Location: the good part of Canada
Posts: 162
line break in textarea: "\n"

line break in html: "<br />"

if you look in the source, you should see the line breaks. use a string replacement function in php to replace "\n" with "<br />" in the output string.
  Reply With Quote
Old 26-06-2007, 14:49   #3 (permalink)
SeanMedia
Senior Member
 
SeanMedia's Avatar
 
Join Date: Jun 2003
Location: Belfast, Ireland
Posts: 416
Send a message via MSN to SeanMedia Send a message via Skype™ to SeanMedia
I've checked the source and I can't see the \n line break.

I also tried
Code:
<%=Replace(results("CourseDetails"),"\n","<br />")%>
in ASP and it didn't work.

EDIT: in ASP it's vbCrLf rather than \n
Thanks mate!
  Reply With Quote
Old 26-06-2007, 18:50   #4 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
Incase someone need it... in php the function is nl2br()
__________________
Quote:
"Why reinvent the wheel"? Simply because it's not round enough and I don't like the treads.
  Reply With Quote
Old 26-06-2007, 20:33   #5 (permalink)
rfresh
Registered User
 
Join Date: Jun 2007
Location: Los Angeles
Posts: 33
Quote:
Originally Posted by SeanMedia
I've checked the source and I can't see the \n line break.

I also tried
Code:
<%=Replace(results("CourseDetails"),"\n","<br />")%>
in ASP and it didn't work.

EDIT: in ASP it's vbCrLf rather than \n
Thanks mate!
OK, I admit I'm not an .ASP programmer (I work in PHP) but don't you have to assign the function results to a variable to see the return value of the function call?

RalphF
Domains & $4.99 Web Hosting
Gold Rush Web Hosting - Domain Registration, Domain Names, Web Hosting
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8