tags:

views:

84

answers:

4

First and foremost, I do understand that MySQL is used for databases, and can be used to update content on a website. What I don't understand is how you actually are able to get MySQl to change the content on a site automatically, or if it is even possible. I really am a beginner so sorry if this question comes comes as noobish. I really don't understand the concept of MYSQL all that much, as I don't understand how websites are able to change the content on their main page daily using MYSQL, Now what I am saying is, if I were to have a website with new information every single day on the main page, and used Mysql as a database, would it be possible to upload for example 7 html files one for each day of the week,to the database, and have each of them displayed on different days, automatically? (This is all a presumption as I don't know how to get the data into a mySql database and if you upload a html file to the database) Sorry for the confusing question and thanks in advance for all the help.

+3  A: 

As you mentioned, MySQL is just a database. You could in theory use Oracle or SQL Server or PostgreSQL, which are all MySQL's "competitors", if you will, in the database space.

What's generally done is that there is a program that sits alongside the web server on the box that reads the content from the database and then translates that content into HTML, where it's served up to you as a web page. This program is usually referred to as a Content Management System or "CMS" (You might want to Wikipedia for "Drupal", which is one popular CMS out there).

Web pages are rarely stored as whole HTML files in MySQL. Usually what's done is that the content (paragraphs of text, comments on a blog, upvotes and downvotes) are stored in some structured format, and the CMS takes that structured data from the database and presents it to you. The upshot of structuring the data in this way is that end-users who want to update content don't have to worry about coding the HTML -- they just write their content and the CMS takes care of the presentation bits.

Dave Markle
+1  A: 

You can have some code/algorithm to rotate the news (articles) in your home page. Those articles can be inserted/stored into your MySQL database.

What I mean by rotate is that for each day a given article is retrieved from the database and shown on your homepage.

The articles can be inserted by hand on a given table in your MySQL database or they can be inserted using some kind of front end (a user form) for that purpose.

For a complete overview of MySQL, this page on Wikipedia is a good hit.

Leniel Macaferi
+3  A: 

MySQL is a database server, and doesn't have any web-related functionality built in. It's just a place to store data (though it's very good at that - it, and other relational database management systems like SQL Server and Oracle, attempt to optimize data storage and retrieval).

There's a layer between the database and the web server that you're missing - the web application framework. That's where your logic goes. If you want to display different data based on the day of the week, you'd program that in your web application:

// ludicrously simplified
if (Date.DayOfWeek = Friday)
    Output "<html>TGIF!</html>"

PHP and ASP.NET are the best known languages for this kind of development.

There are a number of frameworks out there that simplify certain tasks. You can write HTML more or less directly from your code, using the languages above and the right runtimes (the ASP.NET runtime comes with Microsoft's IIS web server, and Zend is popular for PHP). Or with the right tools, you can specify the content each user sees at a very high level.

Michael Petrotta
Wow thanks, that was very informative, so basically if I wanted to create a website that changes the content every day I would need to learn PHP correct? But I still don't understand what MySQL stores, and how it relates to the changing of the content on a website. Sorry if I'm frustrating you with my total lack of knowledge on this subject haha.
Anthony P.
@Anthony: Don't worry about it, we all start somewhere. You can learn PHP if you want a customized website, with features not found elsewhere. It's also a lot of fun to have that kind of control. If you want the power of a database, you'd need to learn how to query MySQL from PHP, which isn't all that hard once you get the hang of it. If all you're looking to do is present a different chunk of content for each user/day of week/etc, look into content management systems, as described by Leniel and Dave in their answers. You'll get up and running faster.
Michael Petrotta
Thanks a lot, I actually understand now. This really helped me out And thanks to everyone else who answered too, you guys rock!
Anthony P.
A: 

I don't know if the other answers have helped you understand, so I'll add a very simplistic answer that I hope will get you over the initial bump.

MySQL will act as an online storage space for you, but it won't provide the website.

In between MySql and the website, there will need to be a program of some sort.

There are many, many different languages and frameworks available to do this, and it's essentially the entire business of web developers to create these programs.

In your particular case, you asked about uploading different pages to MySql and having them displayed for each day of the week.

You wouldn't need to use MySQL or a database at all for this, a few lines of code in most common languages would do this for you, and adding a database would simply add complexity where it wasn't needed.

slomojo