Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a database to store and get html pages for website

Tags:

html

database

I've got a lack of understanding at the moment. I'm developing a website with many articles and instead of creating a .html page for every article, I thought about storing the text into a database and get it from there (somehow) again.

I'm totally unsure if it is the common way to store text in a database. How do all of the "big" websites handle the mass of articles they publish? They won't create single pages neither but instead using a database, I guess.

But how can I achieve this? How can I store whole html files with divs and jquery and stuff into a database and get them when clicking on a link? Might XML be a keyword?

like image 895
sqe Avatar asked Jan 12 '23 23:01

sqe


2 Answers

First of all, you need to clearly understand how things should work.

Clearly the approach of creating a page per article cannot work for multiple reasons:

  • if you have a huge number of articles you'll need to have a huge number of pages
  • if you need to change something small in design, you'll need to make that change for every single stored article

What you need to do is to create a more generic page, which has all the common stuff for all articles in it (a place for title, a place for content). The articles themselves can be stored in a database. When opening a page for a specific article, your application should place the title and content in the right place in that page.

This approach is universal _ it will work for any number of articles.

like image 178
superM Avatar answered Jan 20 '23 23:01

superM


The keywords you are looking for are : Dynamic, Content Management. In order to achieve this, you should learn a scripting language, PHP for example. You will find a lot of tutorials to get started and how to make your website a bit more dynamic.

But you were right about the database part, most blogging systems and other content providers use databases to store all of this in data tables. PHP (and some other languages) would allow you to interface the database and the content you provide to your users.

like image 43
Anthony Teisseire Avatar answered Jan 20 '23 23:01

Anthony Teisseire