May 13

Tournament Brackets in jQuery, PHP and AJAX

We’re having a lan party in a couple of days. Having a handful of competitions we were looking for a good way to show people the brackets and at the same time be able to easily edit them.

I came across a website with a neat little jQuery plugin: http://www.aropupu.fi/bracket/

Quickly whipped together a simple working (yet very messy code) example here:
Tournament Brackets [Download]

Once you restore the tables with the sql file included in the zip you can have your fun with them. It’s not entirely secure but this is just a quick example on how to make it work with jQuery, PHP and Ajax.

Cleaning up the code is something I’ll do when I have some time to spare, in the mean time feel free to use the example for your own competitions.

Aug 14

Developing in PHP

Since July 1st I’m part of the “PC” team of Industria, Group T’s Engineering student organisation. I started right away by learning / refreshing some PHP stuff. It’s really not that hard when you already know a good bit of Java and C.

Anyway, the first webapplication I wrote was a second hand book selling system where members of Group T can sell their expensive books that they don’t need anymore. This being the first time I actually code something that roughly resembles a project in PHP I started out with several files for each view (your own list, add/edit book, list of available books, …) but soon I switched to a simple $_GET action magic, which made editing a lot easier.

As the new academic year is closing in I’m hoping people will start using it more as there are only thirteen books listed at the moment. Even though it’s a pretty simple application I’m proud of it :)

The second (bigger) project I started on is the famous 24h run application that Industria uses to keep track of things before and during the event. I have updated the database and tables that were used last year, removed a lot of unnecessary redundancy and duplicate code. New this year are achievements and badges, these are slightly different from points as their conditions to unlock them are somewhat more special than running a lap at a certain time below a certain duration.

This was a good opportunity to get back into building SQL queries and working with phpMyAdmin instead of using SQLyog. All in all there are currently nine personal and five team achievements. On a user’s profile they are loaded dynamically as they are grabbed from the database. Some generic ones such as “Get X amount of laps/points” can be easily added without any edits to the code.

Continuing this, the pages used during the event to register runners and keep track of laps and laptimes were quite messy as they were written very quickly one or two years ago while receiving no fixes or updates later on. I cleaned them a bit by using includes instead of having duplicate code all over the place. The laptime register page also received a few fail safe features that should help reduce the amount of incorrect registrations of laps.

While I was spending time coding all of these things I encountered many blank pages, internal server errors and such. Often it was because of a semicolon or a bracket that was forgotten or lost, sometimes very frustrating as showing errors was disabled on the server until very recently.

All in all a good start for a year full of PC-goodness!