PDA

Click to See Complete Forum and Search --> : retrieving MySQL string's


ubunreal69
Jun 29th, 2002, 06:27 AM
when a string is saved on the server, how can i retrieve it with the line-breaks still there ? (insert '<br>' where appropriate) :)

Professional
Jun 29th, 2002, 10:55 AM
Explain more....

ubunreal69
Jun 29th, 2002, 11:11 AM
if i had to save a string from an html input field, it should just save it as a straight line od\f text. but i want it to be multiple lines like it was when entered in the field.

Professional
Jun 29th, 2002, 11:18 AM
use the nl2br() function. I believe that should do the trick. Read up on it at http://www.php.net/nl2br/. Never used it though so i cant advise.

ubunreal69
Jun 30th, 2002, 06:30 AM
thanx pro :)

scoutt
Jun 30th, 2002, 08:47 AM
or you can use this

$textboxreplace("(\r\n|\n|\r)", "<br>", $textbox);

ubunreal69
Jul 1st, 2002, 05:25 PM
i was initially thinking along those lines scoutt ;)

but didnt you mean:

$textbox = replace("(\r\n|\n|\r)", "<br>", $textbox);

scoutt
Jul 1st, 2002, 05:58 PM
well close. I did mess up though so it should be like this

$textbox = ereg_replace("(\r\n|\n|\r)", "<br>", $textbox);