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 a self-employed software developer working on Free Software projects, as well as studying for my degree with the Open University. Being pedantic when it comes to detail is fortunately useful for both of these things! A strong believer in free software, I have a few pay-for programs available under the GPLv3 and enjoy reporting bugs and helping to improve various open source projects, including volunteering at Wimborne Model Town to work on their river control system.

Leave a Reply

Your email address will not be published. Required fields are marked *