title: PHP - Displaying html from mysql text field in a div
body: <p>I've some problem with displaying html tags after I retrieve them from a text field in my mysql DB. </p>
  
  <p>my code looks something like this:</p>
  
  <pre><code>&lt;div class='textDiv'&gt;&lt;? echo htmlspecialchars_decode(str_replace("\r\n", "&lt;br&gt;", $row["textField"]), ENT_NOQUOTES);?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>So when the text field in mysql has only plain text, everything is fine, but when I add a link inside the text, I get a line break before and after the link tag, and the displayed text becomes line this:</p>
  
  <pre><code>Some text justified over the div, then a sudden break
  text with link to source
  then the text continues justified as normal
  </code></pre>
  
  <p>However, HTML code generated by the script is like this: </p>
  
  <pre><code>&lt;div class="textDiv"&gt;Senior Advisor said in a &lt;a href="test.html"&gt;media interview&lt;/a&gt; that the overall monetary policy tone is shifting towards...&lt;/div&gt;
  </code></pre>
  
  <p>Do you guys have any idea why this happens and how to fix it? So that the text is displayed smoothly without line breaks?</p>