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

Recommended Answers

All 5 Replies

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.

Sir,

I am new to MySql.

I am facing Installation Problem.

Kindly do the Needful.

Ashwin Perti

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.

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.

nl2br is the function to replace enter with <br>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.