daniel daniel - 4 years ago 156
PHP Question

Read Enter text in php

I have a problem. I have a text that called from database. In database, the text has an enter text. Here is the picture:

enter image description here

But in my website, it has no enter. Here is the picture.

enter image description here

How to read enter in php?

Here is my code:

$ambil = mysql_query("SELECT * FROM blog WHERE id_blog = '" . $id . "' ");
$deskripsi = $tamp->deskripsi;

<p><?php echo $deskripsi; ?></p>

Thank you before :)

Answer Source

Try <p style="white-space: pre">.

You could also replace the newlines in the text with <br> tags.

The latter can be accomplished like this (hat tip to @andrewsi):

<p><?php echo nl2br($deskripsi); ?></p>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download