That PHP code

Well, I finally seem to have pulled it all together. Both the Countdown list on the top right of the main page and the Birthday and Anniversary lists on Important Dates have been implemented using the code. A little bit of clean up work and I expect to post it for download. I’m even thinking of turning it into an article for one of the PHP magazines or webzines, probably know more about that later.

Definitely need to say thanks to Andre Naess for his replies to my sometimes blithering doltishness in the comp.lang.php newsgroup. Thanks Andre! And thanks to the people who put their time and effort into the MySQL open source database project (MySQL Manual | 6.3.4 Date and Time Functions was incredibly useful) and, of course, PHP.

So, what does this class do? First, store some information about some number of events into a database: event name, the date it occurs on, associated URL, category, and active status. The basic code grabs the records for a given category, calculates the number of days until the event, filters them based on active status and that the event takes place in the future, and provides a string formatted for inclusion in an HTML page (the list used on the main page). An elaboration, called a child class in object-oriented programming terms, customizes the filtering (all birthdays by definition are in the past), and uses a different formatting for the result; the number of days until the next birthday is calculated and used to emphasize dates less 31 days away.

So essentially this is the guts of what could be a web-based reminder service, not totally unlike Userland’s MailToTheFuture, that could be enhanced to support multiple users and some type of notification service. One could also add additional child classes to handle different types of events. But I wrote this mostly for my own use, to stretch my programming muscles a tad and to have a more automated way to handle the Countdowns list.