SEO Packages

Generating Web Pages with PHP

October 29, 2011EditorPHP, Web DevelopmentComments Off

PHP, or PHP: Hypertext Preprocessor, is a very simple programming language that turns the paradigm for dynamic web page creation inside out. While other dynamic scripting languages, like PERL, will have you create a web page and keep the scripts on the server outside the page, PHP has you integrate the script directly into the page.

This makes it much easier for the average home programmer to create great dynamic pages, while still retaining a robust programming repertoire for the most advanced programmers. On top of that, PHP is an open-source language and works with most versions of SQL and with other relational database programs.

Why Generate Pages?

When most people start programming HTML web pages, they are creating static pages: pages on which nothing much happens, just the delivery of information. The page is contained completely in itself, and once you’ve published it to the Web, it’s not going anywhere.

A PHP generated page is very different. It is generally integrated with a back-end database and changes according to what is contained in that database.

For instance, suppose you have an electronic picture album you want to deliver to your website. It’s going to be changing fairly frequently because you take a lot of pictures, and you’d like the most recent ones to always be available to you.

Instead of recreating your page every time you take a new picture and upload the page with the new pictures, you create a single database that includes all your pictures and upload it to your web server. Then you create a single PHP page that has a script to dynamically create a page to display each of the pictures you have in your database.

(The following script shows how to put together a single page with all your pictures on it.  You can also create a script that generates multiple pages with each picture on it, but because of the different ways your viewers might access those pages, this sort of script is too complicated for this article.)

Now you have two files on your server: the database and the PHP page. Those viewing your page, however, will see your pictures, labeled with titles, dynamically created each time they look for a new page. Better yet, you never have to change the PHP page when you add new pictures or remove old ones; you simply change your database and upload it again.

There are hundreds of applications for this technology: dynamic online catalogs, robust ecommerce systems, online dictionaries, etc. But for the purposes of this article, we’ll just talk about that picture-album page.

Creating The Database

In some ways, all databases are alike. They are collections of information categorized so that each item carries more information than it would by itself. A relational database categorizes information so that you can see each item’s relationship with each other item.

For our purposes, you only need one table in your database with two columns. One column will hold a description or title of a picture, and the second column will hold the image of the picture as a JPG file. It doesn’t matter what format the database is in, but again for simplicity we will put it in an Access database:



Jim’s Fourth Birthday with Cake


Jim’s Fourth Birhday opening presents


Name your database “Mypictures” and your table “mypicturetable”. That’s as complicated as it needs to be.


Related Posts

Comments are closed.