31/10/2017 Website update using PHP and SQL

Hi all,

My website has been updated!

It’s a bit weird for me to make a major revision to something I created such a short time ago, so as you may have guessed, I have a very good reason for doing so. Namely:

It used to be a complete pain to maintain it.

My website used to have manually-coded pages for museums, downloads, and the counters were just very small files in the same directory as the downloads. This might not seem like a terrible idea at first, but when you have over 281 files, it becomes rather a pain to maintain XD.

As it were, if I wanted to change just one thing – say, how the table data was formatted – it was very likely that I would have had to modify every row in every single table on the website, which literally took me hours and was incredibly repetitive and boring.

Clearly, this wasn’t going to work in the long term, so after studying some of a PHP/SQL course in Udemy, an online learning platform, I decided to use more PHP and SQL, surprisingly!

The new design

To replace my terrible old design, I wrote a bunch of PHP functions to do things like build tables, and create the in-page navigation using a relational SQL database I designed, which works out much better. My only concern with doing this was keeping my database and table names private, while still keeping the source code publicly available. I talked about this a bit in this post. In the end, I made a sort of framework that anyone else can use and adapt that uses tables and database-related stuff defined in two separate files, includes/db.php, and includes/tables.php. I have not included either of these files in the github repository for security reasons, but you can easily make your own.

I will create some documents soon that demonstrate the table formats I’ve used, and the names of the variables I used to reference tables, to make it even easier to use this code for your own site. Granted, you can figure it out pretty easily from the source code anyway (look in includes/functions.php), but it can’t hurt to make it simpler. I’ll also add some info to the Readme.md file in the github repository to make it easier to understand how to use it.to automate using tables.

This new design means that I now only have to add new information about downloads in one place, and all the in-page navigation, downloads, and museums are automatically recreated, because they’re built directly from the information in the database tables. SO much better 🙂


I have made my website better so I can bear the burden of maintaining it with less complaining :). You can also use this code to help build your website if you like.

That’s it from me, but stay tuned for more OS reviews and PXE-boot-related things 🙂


Tagged , , , . Bookmark the permalink.

About Hamish McIntyre-Bhatty

I'm currently studying for a Computing and IT degree with the Open University, and am a software developer as well. I enjoy coding in Python, C++ (still learning), and Java. Having written 4 open-source programs (hosted on launchpad.net), set up my own website, and started volunteering at Wimborne Model Town to work on their river control system, I still find the time to enjoy cycling, acting, photography, and playing bass guitar. I go climbing every now and then as well. As you may have guessed, I also enjoy blogging :)

Leave a Reply

Your email address will not be published.