0

Hi,

I have a text data type field in MySQL table that I need to read out to a page. When the value is entered into this text field the value will have returns as follows:

------------------
TEST TEST aaaaaaaa

asdasdasdfas

3rd lineasadas
----------------
When I read this value out and display in php page in the browser, the returns are not there and I get it all in one line:
-----------------------
TEST TEST aaaaaaaaasdasdasdfas3rd lineasadas
-------------------

What can I do to have he returns show up?

Thanks,
Juls

5
Contributors
5
Replies
7
Views
12 Years
Discussion Span
Last Post by Mckcvision
0

In the webpage you can use str_replace:

$text = $row;
$text = str_replace("\n", "<br>", $text);
echo $text;

To prnt in one line, ignore the str_replace part.

0

Juls - PHP has a built in function to convert line feeds to <br /> elements. It is nl2br, and it's use is:

echo( nl2br("this is a line\nthis is another line") )
/** prints as
this is a line<br />
this is another line
*/

ashwinperti - suggest you start your own thread rather than trying to hijack others. You'll get a better response if you describe what your problem is and what your operating environment is.

0

nl2br is the function which assist you to change enter as jump line.

Hope it helps

In the webpage you can use str_replace:

$text = $row;
$text = str_replace("\n", "<br>", $text);
echo $text;

To prnt in one line, ignore the str_replace part.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.