Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-08-2003, 06:43 PM   PM User | #1
stryper
Registered User

 
Join Date: Apr 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
stryper is an unknown quantity at this point
showing text captured with a text area input

hello, i have this problem in a page i get long user text with a input text area box, after that i save it in a Mysql table and later i show that text in a browser, but if the user insert spacen between paragraph it doesnt save them it show the text as a long single line of thex, how can i get this spaces (\n) to be showed as user inserts the text.
stryper is offline   Reply With Quote
Old 04-08-2003, 07:00 PM   PM User | #2
missing-score
Senior Coder


 
missing-score's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
missing-score is on a distinguished road
I think I know what you mean.

You could do a javascript replace

Code:
document.whatever.textarea.value.replace(/\n/g,'<br />');
Or PHP replace...

PHP Code:
<?php

ereg_replace
("\n",'<br />',$form_value);

?>
Or there is a PHP function that automatically does this.

PHP Code:
<?php

nl2br
($form_value);

?>
Hope this helps.
missing-score is offline   Reply With Quote
Old 04-10-2003, 03:04 PM   PM User | #3
thox
Registered User

 
Join Date: Feb 2003
Location: Berkshire, UK
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
thox is an unknown quantity at this point
you can also use <pre></pre> for displaying preformatted text. then you could also add some nice css to stop it from looking too out of place.
thox is offline   Reply With Quote
Old 04-10-2003, 04:51 PM   PM User | #4
missing-score
Senior Coder


 
missing-score's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
missing-score is on a distinguished road
oh yeah....

I forgot about that.

I have never actually used the <pre> tag before, even though I know what it does. Guess thats just me
missing-score is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:32 AM.


Advertisement
Log in to turn off these ads.