skip to Main Content

So, I’m making a website for a music collective that I’m in, and on that site there’s a page where you can see all the albums (a simple 300 x 300px hyper link image) that redirects you to a bandcamp page.

As of now, if I want to add another album I must go into the HTML file and manually add it. My question is, is it possible to use MYSQL to add albums?
And by that I mean that everytime I “add an album” in MYSQL it will edit the HTML automatically? And if so, how do I do?

This is how the code looks:

HTML

<div class="product-box fade-in-drop">
    <!-- album -->
    <div class ="album">
            <a href="example.com"><img src="exmaple.com"></a>
    </div>
</div>

EDIT:
It might be worth noting that I use a web hosting service that has a cPanel so I have database access, I just don’t know how to write the code to make my plan possible.

3

Answers


  1. It’s not possible with pure HTML. You need some server side logic to query the database, like PHP, python, perl etc., and use the data to build the HTML dynamically.

    You can’t use HTML5 / Javascript dynamics because they are run by the client, your database is on the server.

    Login or Signup to reply.
  2. I apologize if I am assuming too much here.

    Your question implies that you want to move from a static website to a dynamic one where, instead of the HTML having static data, your information comes to the page by way of a web server making a connection to a database via some sort of intermediary, third party software. This is much more complicated than what you are doing now, but it is certainly not the most difficult task for creating a simple website that has outgrown the needs of a static page.

    Here is a nice tutorial I have found, for an introduction. But I would recommend getting a book on LAMP development, particularly one that is more current than that article. You also might want to look into Drupal, though that might be overkill depending upon how simple your needs are.

    Login or Signup to reply.
  3. What you can do based on the information you have given us is take the data that exists currently in the cPanel database access and find some way to copy that data into MySQL whether it’s importing it directly, using Excel, or whatever. That would be the best way to go and then set up a connection to the MySQL database server. As mentioned you can use PHP, python, etc. to manipulate that data and have access to read/write that data through your site. Just by googling the basics you should be set on the right path to get a working dynamic website.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search