Re: html text area and mysql text fields

From: Date: Tue, 27 Jul 2004 21:50:44 +0000
Subject: Re: html text area and mysql text fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-192033@lists.php.net to get a copy of this message
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 -- - + - + - + - + - + - + - + - + - + - + - + - + - Enda Nagle +353 86 168 0774 enda@category9.com www.category9.com - + - + - + - + - + - + - + - + - + - + - + - + - On 27/07/2004 22:55, "Matthew Sims" <matt@killermookie.org> 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"]);

« previous php.general (#192033) next »