0

I am using a jquery editor.And the content will be saved in the database along with the html tags . That is for example I have typed "aneesh" in the editor and using editor makes the text bold and italics the saved the content to db . So the content will be saved in the db along with text and html tags

Now i want take the content from db and want show the text in formated ways that is need to transform the html tags that in my the content want to show like this aneesh Is there any way for this please help me

7
  • 1
    Do U try do it self? Do U get some errors?
    – Sergey
    Jul 6, 2012 at 8:31
  • what is the problem?? you can simply print it on a div
    – xkeshav
    Jul 6, 2012 at 8:32
  • I don't understand, if snip like this <b>aneesh</b> is saved on your database, there will be no problem in displaying it in bold when you echo it.
    – deex
    Jul 6, 2012 at 8:33
  • no while printing it shows along with the tags Jul 6, 2012 at 8:33
  • So you want it to be printed not in bold but by exactly the way it is in database?
    – deex
    Jul 6, 2012 at 8:34

5 Answers 5

1

To store and retrieve html you should use htmlspecialchars() - this preserves html tags etc etc when saving and htmlspecialchars_decode() - this converts them back to proper html that can be displayed - when displaying the retrieved content.

Storing using this and calling the decode function when populating the textarea behind the wysiwig editor will/should have kept everything preserved.

0

Or you can also use htmlspecialchars()

$a=htmlspecialchars($a);
<text>$a</text>

wud help u save and retrieve the html characters

0
0

Just select the data out of database (i'm using PDO): and echo/post the result to the document without string formating:

$sql = 'SELECT * FROM table;';
$stmt = $DB->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);

echo $row['result'];
0

if you have content with html tags like i-e <b>Hello</b> in the database, and when you return it from the database again, the jquery editor that you are using will automatically remove those tags and will transform your text again and make it i-e bold (if hello in case). There is no need to do anything but just echo it out.

0

you need to use javascript for better and easy solution.

get raw html content from db (with php) to show web browser (with javascript): innerHTML or .html() (JQuery)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.