user3070142 user3070142 - 6 months ago 20
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>


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.