RE: [PHP] How can I format text in textarea?

2005-08-30 Thread Murray @ PlanetThoughtful
 Hi
 When I enter text as more than on paragrahs in a textarea field,The text
 is displayed in one solid block of text even though I have entered it in
 paragraphs.
 How I can  to insert line breaks in the text. (The values of textarea is
 stored in database and then displayed.)
 
 
 Bushra

Hi Bushra,

When displaying the data stored in your db from a textarea field, use the
nl2br() function.

This converts newlines in the data into br / html tags. You're currently
not seeing the paragraph breaks because the HTML specification doesn't
display newline / carriage returns when a page is rendered in a browser --
you have to specifically indicate where paragraph breaks should take place
using HTML tags.

Eg:

echo nl2br($data_from_db_entered_via_textarea);

See: http://au2.php.net/nl2br

Regards,

Murray
---
http://www.planetthoughtful.org
Building a thoughtful planet...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I format text in textarea?

2005-08-29 Thread Jasper Bryant-Greene

bushra wrote:

Hi
When I enter text as more than on paragrahs in a textarea field,The text 
is displayed in one solid block of text even though I have entered it in 
paragraphs. How I can  to insert line breaks in the text. (The values of 
textarea is stored in database and then displayed.)


If you have the text in $string, then this will output it safely and 
with correct line breaks:


print(nl2br(htmlspecialchars($string)));

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php