Welcome Guest, Not a member yet? Register   Sign In
I can't retreive HTML content from database
#1

[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?
#2

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

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




Theme © iAndrew 2016 - Forum software by © MyBB