HTML Tags in database


how can i save a string with html tags into database and retrive it back in php. this most likely occurs while using a ckeditor


just like you do it anyway with other strings: connect, prepare statement, query.


Try following example. I use jQuery, php

	<header>Welcome to your new home</header>


var html = $(’#my_home’).html();
html = JSON.stringify(html);
$.post(‘php_file_name’, {html: html}, function(data) {
//do some things here

$html = htmlentities(($_POST["html"]);

You may now insert into or update the table using appropriate statement
If you check your table, all html tags will be converted to their entities.

Now to download the content of the table column to the client side (browser).
Assume table column is called lists, use html_entity_decode($row["lists"])

(if using associative array method) or html_entity_decode($row[x]) where column index is x, $row is the result of the query.

Get more information from