Re: textbox+database
| From: | Kevin Stone | Date: | Wed, 30 Jul 2003 22:18:00 +0000 |
| Subject: | Re: textbox+database | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157612@lists.php.net to get a copy of this message | ||
"Mehdi Achour" <didou@keliglia.com> wrote in message
news:3F283A11.1060104@keliglia.com...
> Patrik Fomin wrote:
> > hi, i have a textbox, after someone puts text into it, it saves into the
> > database,
> > <textarea cols="2" rows="2"></textarea>
> >
> >
> > when it saves to the database the formattion in the textbox dosent work
> > properly,
> > eg:
> > i add this:
> >
> > Test
> >
> > Test
> >
> >
> > Hello
> >
> >
> > and when i retrive the text from the database it looks like this:
> > TestTestHello
> >
> > is there anyway to save (enter formattions)?
> >
>
> echo nl2br($data_from_database); // see php.net/nl2br
>
> Mehdi
Not to be picky but this is considerablly more reliable..
// Convert end of line to <br>..
$str = ereg_replace("\n|\r|\r\n", '<br>', $str);
// Convert <br> to end of line..
Not to be picky but this is considerablly more reliable..
$str = ereg_replace("<br>", "\n", $str);
- Kevin