×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Is it acceptable to store HTML in a database?

Is it acceptable to store HTML in a database?

Is it acceptable to store HTML in a database?

(OP)
I have always tried to keep a separation in my coding (N-tiered development it used to be called; now in .Net it is MVC) but it has recently come up that it can be "better" to store some code inside database tables. This seems REALLY hard to troubleshoot and / or maintain.

Does anybody reputable say this is a good idea?

Thanks.

RE: Is it acceptable to store HTML in a database?

Not sure if you consider me reputable, but personally, I would not store important HTML in a database.

As you say, maintaining will a pain as you would need either an interface to your DB to edit the HTML, or direct access to it, and edit in a small text editor directly there.

Other than that, obfuscating where the HTML is coming from can cause issues when another developer comes along to maintain it, and would need to search tables to find HTML.

Also, I can see no database schema where having an HTML table would make sense.

The only thing I can see that would store some HTML in a DB is a blog or forum. Where it would be storing the post's HTML. But that should be very basic, and would likely not need to be edited directly but through a web based editor.

But I think storing HTML that is an actual part of the website design and layout is just making things much more cumbersome than they need to be.

Also how is this related to PHP? PHP would just echo out the HTML. I think maybe posting in the forum for the DB you are using may have been more adequate.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Is it acceptable to store HTML in a database?

Quote:

Does anybody reputable say this is a good idea?

It's not a good idea for the reasons you mentioned.

Personally I've always preferred using a kind of pseudo markup language, much like BBCode does and just expand it at 'run time'.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Is it acceptable to store HTML in a database?

(OP)
Thanks for the thoughts.

What is the relevance to PHP? Well, I guess it's only a small tie-in.

<story type='long, boring'>

I have a PHP subroutine that you can pass some data and a css class and it will build an HTML table from that. I've had it for years and it works pretty well. Usually it's not the final output, but it's a development placeholder. (Although, in a couple of instances it's worked just fine for the finished product!)

My boss has taken up programming as a hobby, found this code and loved it! He decided to move a lot of his presentation code into stored procedures & tables and pass that into my HTML table generator.

We recently got a new domain name and split the site in two and I had to search through the tables, views, & stored procedures to make changes.

</story>

When I searched for "HTML stored in database", I was surprised how many people liked the idea. I thought it could be related to development for mobile apps.

Thanks for the thoughts.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close