user3070142 user3070142 - 1 year ago 66
HTML Question

long text in php doesn't appear correctly with html

I would like to see a long text that was selected from the databases, but it appears on a single line and it is not complete, i.e., no return to the line. If I try to manually type the text instead of the variable, it works very well.

<div class="container">
<h4><a href="school.php">School</a></h4>
<p><?php echo $question;?></p>
<p><label style="color: gray"> 13/03/2016 </label></p>

Answer Source

Use the nl2br() while inserting the data into the database.

$text = nl2br(htmlentities($input, ENT_QUOTES, 'UTF-8'));

This will preserve the whitespace while storing into the database. Use it in the insert function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download