Jump to content

Different ways of building a site HTML, PHP, MySQL+PHP,...


Recommended Posts

Hi all,

 

I have built a site where the pages are stored on a mysql database and there is one index.php file that all the page data is loaded into. Is this a good way of building a site. Each page in the database is only HTML content. I understand that I cannot put php or javascript into the database, is this correct?

 

:confused:

It doesn't sound great in all honesty. You shouldn't be putting entire pages into a database and just retrieving them its a very bad design and I'd imagine puts strain on the servers. You should be writing HTML in PHP pages, ideally, and putting snippets of PHP code in to do what you want.

 

A combination of HTML, CSS, PHP and a MySQL back-end (dependent on whether or not its needed) are ideal but your styling, and DOM etc shouldn't really be kept in the database in its entirety.

No, don't put entire HTML pages in a database.  Databases are for data.

 

The basic idea is this:

 

You store data in a database.

Requests for that data are handled by PHP, which queries the database for that data.

PHP then puts the data in the correct template so it can be viewed.

 

These templates are PHP files, but are largely HTML.  There's just enough PHP within them to echo the data at the appropriate spot in the markup.

Yes. The reason being is that if your website changes (re-design for example) should not include editing the content in your database. Storing everything in the DB has certain drawbacks you may not be aware of. For example imagine the client asks you to display his latest tweets on his website in real-time. You can't put it in your DB.. so this means you will have a copy of your website in the DB and now also on the file system for those pages that require the tweets. This is just off the bat, I am sure there are more drawbacks, but I imagine you now understand when storing your entire website in the DB is not a good idea.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.