Thursday, August 20, 2009

Web site progress

I made a bit of progress with the news web site today.

First, I added a separate page for displaying a news story. I don't want the news story on the front page, just the headlines and teaser. Adding a new page was easy, linking to it was easy, and changing the query to retreive a specific story... was hard.

I needed a way to specify a story; the database had no unique key for stories. It was a minor change to add the column and make it auto-increment in SQL. (I dropped the table, changed the 'create' scripts, and re-added the table and data.)

For a while, PHP was having problems. I thought it was an SQL error, but it turns out to have been a PHP syntax problem. I had changed "$q" to "q" in my code, and PHP did not like it. The errors from PHP were not very helpful, and in fact lead me down the wrong path. I had to get up and walk around for a bit, and then come back to the code with "fresh eyes". Once I did, the problem was obvious.

Once that problem was solved, I then had two web pages with a fair amount of identical HTML code. I learned a bit about PHP's "include" capabilities and used them to combine the common HTML into a single module. The result was a cleaner set of web pages.

I still have a bit of clean-up to perform. But that can wait until tomorrow. I want to absorb what I learned with my adventures today.

No comments:

Post a Comment