Search code examples
htmlwysiwyg

Add article markup in database


I am creating a CMS (IN ASP) and I add some content via my CMS into the database.

But I am going to use a WYSIWYG-editor. So I can markup my content with using colours, making some words bold etc.

But how can I save the markup which I made with the WYSIWYG-editor into the database?

For example:

I want to save this article with my WYSIWYG-editor(with "name" as bold):

Hello my name is Mike.

Do I need to save this as below in the database:

Hello my <b>name</b> is Mike.

Or how do I need to save content that contains markup? Because I must be able to retrieve the content from the database and show the articles with the markup they contain on the website.

EDIT: I'm using MySQL


Solution

  • There is absolutely nothing wrong with saving markup and content together in the database.

    Just be sure to use the correct datatype and set a reasonable char limit, something like varchar(5000) depending on the column and what the data is being used for obviously.

    How you save this to the database will be down to the DBMS you're using, which you haven't specified