14 December, 2003

A lot has happened behind the scenes at my website. One of the biggest concerns I have had with doing an online comic — aside from being able to maintain it — was what to do with all the damn files. Using HTML, every single comic would need its own page, which could get to be a lot of pages. For example, there are currently 202 comics in various stages of deployment, which would eventually require 202 HTML files. This left me very concerned about what to do if I should ever decide to change my website. After all, who wants to change 202 files? So, off-and-on, I've been trying to figure out how to have a single comics page that would know what comic was being displayed and also know what comic should go before and after it.

Now, I had done some work with Javascript, but this seemed like a big hassle. Also, I couldn't figure out how to tell the web page what comic should be displayed. If I could tell the page what comic to display, then figuring out what comes before and after should be no problem at all. This just takes a little addition and subtraction. And, don't forget to make sure you haven't gone too far up or down the scale. I wouldn't want to accidentally be trying to display comic number negative five or something like that.

Anyway, I wasn't getting anywhere with Javascript. Not that I was trying very hard. But, I wasn't getting anywhere. So, one day, I noticed that Sluggy Freelance's URLs end with the .php file extension. I figured that this must be another scripting language, but I couldn't seem to figure out anything about it. So, time slipped by, and I didn't give the idea much thought.

One day, I noticed that, which is one of my favorite websites, had a PHP tutorial. I checked it out and immediately noticed the code resemblance to C. I swear everybody copies C. Actually something I've always wondered but never bothered to look into was what did come first. Did Perl imitate C syntax or the other way around? Of course, they could both be lifting from another source, but I always think of C and Perl. Don't even talk to me about Java. Is it just me or did somebody take C, strip out all the pointers and pointers-to-functions, and just rename what was left Java? But, I digress.

PHP looked more promising than Javascript, but I kept running into the same brick wall. There was absolutely no explanation on how to pass information into the PHP code. Sure, the first part was obvious. I could tell from looking at other people's websites that you had to stick a question mark and equals sign on to the end of the URL; unfortunately, I couldn't find a single solitary word on how to grab that info from the URL.

This was a trend I had started to notice with my explorations of Java and Javascript. Nobody wants to tell you how to read input. It seems to be one of those secret of the temple-only the initiated may know things. Really pissed me off.

So, I gave-up, again. No, really, when did I have time to work on this anyway. So, it stewed at the back of my mind, and I knew that one day I was going to have to deal with the fact that I might have several hundred HTML files to deal with because of all the comics.

It was about a week ago that I was thinking about all of this again. I now had 202 comics to worry about, and I was concerned about the hassle that would be involved with updating all of their individual pages. So, I went back to to try and see if I had missed something. I even followed their links to other PHP sites, including, which is supposed to be the source of PHP. Still no luck. This sucked. I mean how could they neglect something so mind-bogglingly important?

And, then in frustration, I wondered if it was something stupid. Maybe, all of these people at all of these websites thought that the way to catch input in PHP was so obvious that it never even occurred to them that it was just the opposite. So, I thought that maybe you don't catch input, and I thought that this would be a really insanely stupid way to handle it. You throw it, and it sticks. You use it if you remember. You can ignore it, and it just doesn't matter. There is absolutely no error control with this method. I couldn't think of a more idiotic way to handle passing data into a file so I figured that this must be the answer.

See, it is simple. Simple and stupid. So, simple and stupid that it never even occurs to anybody that they need to explain it. All you have to do if you want to pass info such as the correct comic to display into the file is to stick it onto the URL. Okay, here goes. URL blah blah blah. End with .php-question mark-variable name-equals sign-number. Bingo. It worked.

I was both excited and shocked and stupefied all at the same time. I was excited because I had finally figured out something I had been casually wondering about for a year. I was shocked because this method is both mind-bogglingly stupid and dangerous, and I was stupefied because I hadn't thought of it before.

Okay, it took about a second to get over being shocked and stupefied which just left excitement. I could now design a single PHP page that could display every single comic. I wouldn't need 202 HTML pages any more. As long as the number of the comic you wanted displayed was included as part of the URL, the single PHP page would be able to display it as well as give you access to the comic right before it and the one after it if those things existed. I swear I've been so tired and depressed over my crappy job and miscellaneous crap that discovering this secret of PHP was a real joy.

So, last Sunday, I figured out the secret of feeding the desired comic's number to the PHP page. After some time spent trolling around, I figured out a method for handling what to do if no comic's number is included as part of the URL. Also, I handled what to do if the number thrown is outside the comic's range. The only thing that bothers me is that I couldn't figure out how to handle things other than numbers being thrown at the page. I saw a couple examples of how to handle this at, but I couldn't get any of them to work. So, it is still possible to intentionally make the PHP comic viewer crap-out. I'm not happy about this, but I'll figure something out one of these days.

Late last Sunday night, I realized that I could do even more. I knew that PHP had a date-function, and I realized that I could use this to have my website automatically update the comic. Now, this realization was even better than discovering how to pass info into the page. If I could get this to work, then I wouldn't be such a slave to my website. I would be able to ignore it for days on end, and it would still update my comic right on schedule. I could take vacations and go see my parents without having to put up apologies as to why there wouldn't be another comic for days on end.

Last Monday night, I worked on this, and by midnight, I had my automatic update code working. Of course, since my web host is in New Jersey or some such place, the comic was updating at 9 PM instead of midnight, but I didn't care. It was updating all by itself. I was free.

Of course, I couldn't leave well enough alone. Tuesday night, I completely redesigned the archive page. The page would only display the titles of each chapter, and you would have to click on one in-order to pick a comic. It sounded really cool, but I just didn't like how it looked on the page. Kind of all scrunched together. I guess I just don't have enough comics done for this to look cool.

However, I had used nested loops in-order to create the archive, and they were working really well. So, Wednesday night, I abandoned the more extreme parts of my archive design but kept the nested loops that were creating the individual tables. It just made for a less cluttered and easier to deal with page.

Thursday night, I added compensation for East Coast time, and the comic began successfully updating at midnight on the West Coast. Wait, I only tested this Thursday night. I didn't include this code tweak in the public version of my website until Saturday. But, I designed and tested it Thursday night so who cares.

Friday. Well, Friday, I was home sick. In fact, I'm still coughing and blowing my nose today but feeling much better than I did yesterday.

Anyway, Friday morning, it occurred to me that the archive page repeated the same code block over and over again, and I thought that I might be able to handle all of this with a function. Well, that code took hardly any time at all to design, but it is so cool. If you go to comicsArchive.php and use your web browser to view the source code, then you'll see approximately a ton and a half of HTML table code. However, if you were ever able to view the unexecuted comicsArchive.php file, you would find a very small file.

So, that is how I spent my week. No progress on the comic. There are still only 202 comics, and I still don't know how much longer episode three is going to last. I even got some writing done on The Etymology of Fire but that was almost two weeks ago now. All I did was completely redesign the backend of the comic section of my website. Yippee!

copyright © 2003 by keith d. jones – all rights reserved
home | books | music | fiction | spoken word | comics | journal | news