RE: How can I format text in textarea?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux