Re: Carriage returns in a field

From: Date: Mon, 26 Apr 2004 15:07:05 +0000
Subject: Re: Carriage returns in a field
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184662@lists.php.net to get a copy of this message
Brian Dunning wrote:
I am using a <textarea> entry field and I want returns to be preserved when that form output is shown on a page later. Currently returns are not being preserved: they just output as a space so the text is all one big paragraph. 1) Do I need to do anything special when I write the <textarea> to mysql, and 2) Do I need to do anything special when I output the query result to preserve the returns that were typed? TIA, - Brian
nl2br is the answer. You can either use it before you enter the string in the DB (faster), or when displaying (there is not any problem when you want to edit it later - but this can be easily solved by removing all '<br />' tags).

« previous php.general (#184662) next »