> i keep the string intact as well, for that exact reason, when you want > to edit dynamically, i dont want all sorts of html tags in my > textarea. So, the solution i found works, is to use the php funtion > nl2br(). use that when displaying the info in html., that way you dont > actually change the original text. > > JAson > > On Tue, 27 Jul 2004 22:50:44 +0100, Enda Nagle - Lists > <[EMAIL PROTECTED]> wrote: >> I usually leave the string intact in the database because if you need to >> show it in an admin area or something, you donšt need to convert it back >> again before populating the text area. >> >> Suppose it just comes down to personal preference... Or is there a >> specific >> benefit to doing it this way? >> >> Regards >> >> Enda >> On 27/07/2004 22:55, "Matthew Sims" <[EMAIL PROTECTED]> wrote: >> >> >> > Hi, >> >> > >> >> > If I have a html textarea for inputting text into a database text >> field >> >> > how can I keep the formatting of the entered text? >> >> > >> >> > i.e. on the html textarea if the user enters carriage returns i.e. >> a new >> >> > paragraph I want that to go into the database then when I retrieve >> it and >> >> > display it on a normal html page I want to keep those carriage >> returns! >> >> > >> >> > Thanks >> >> > >> >> > Matt >> > >> > Before injecting textarea data into a DB use this: >> > >> > $_POST["textarea"] = str_replace("\n","<br>",$_POST["textarea"]); >> > >> > When retrieving data from the DB for a textarea use this before >> displaying: >> > >> > $_POST["textarea"] = str_replace("<br>","\n",$_POST["textarea"]);
I think the reason why I started using the above two lines is becasue I had created a mailer program for my work where co-workers can send mail through the website. Anyway, I was using the function nl2br to handle my newlines/breaks but when receiving the email through Outlook everything was double spaced. It turns out that nl2br was inserting a "\r\n" combination. After some help through Google Groups it was suggested that the two lines above would pretty much do the same and keep everything intact with spacing. So it's what I've been using ever since for anything textarea out of habit. :) -- --Matthew Sims --<http://killermookie.org> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php