Html in my database!

I came across something that I donโ€™t know where to start.

I currently have a news section on my website, news is being added to the database. However, it is very boring and has no formatting!

How can I let the administrator add news to make it bold or underlined, as well as have color, etc. Is it possible to save this in the database as usual.

Sorry if this is a really stupid question, but this is something that I have not come across before!

thank

+5
source share
5 answers

HTML , HTML, , , .

( , HTML , script -injection), : <div> , .

HTML- HTML- "", . , . , , , . *italic*, **bold**, http:โ€‹//www.example.com/ โ†’ italic, , http://www.example.com/.

. , , Markdown.

(Markdown , , HTML- , , , `-quotes. , : bbcode, reST, Textile ..)

+2

CKEditor , , html. CKEditor . , HTML.

+1

:

INSERT INTO tbl (html_text) values ('<h1>Hello, world.</h1>')

(, .)

+1

HTML, varchar (max), , HTML, (.. -). , , HTML.

+1

You can use any number of text editors to provide text formatting functionality. Then you can save this to the database just like regular text.

Just make sure HTML encodes your output.

I prefer CKEditor for my rich text editor. Very reliable, mature and cross platform.

+1
source

All Articles