CodeIgniter Forums
I can't retreive HTML content from database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: I can't retreive HTML content from database (/showthread.php?tid=60295)



I can't retreive HTML content from database - El Forum - 02-24-2014

[eluser]Unknown[/eluser]
Hi everyone.

I trying to select some html content from Mysql database usign CI, but it return only inner text of first paragraph.

Here is example:
Data in mysql field "desc":
Code:
<p>First paragraph text</p><p>Second paragraph text</p><p>Third paragraph text</p>

Controller:
Code:
class Welcome extends CI_Controller {
public function index()
{
  $query = $this->db->query("SELECT * from rss where id=20844");
  $row = $query->row();
     echo $row->id;
     echo $row->title;
     echo $row->desc;
  $this->load->view('welcome_message');
}
}

Output:
Quote:20844
Title
First paragraph text

What I do wrong?


I can't retreive HTML content from database - El Forum - 02-24-2014

[eluser]InsiteFX[/eluser]
You need to encode it first using htmlentities or htmlspecialchars, then decode it using html_entity_decode.


I can't retreive HTML content from database - El Forum - 02-25-2014

[eluser]Unknown[/eluser]
Many thanks. I works.