Creating an HTML Thumbnail Table via a PHP Script
Note: This page is concerned with generating HTML when you already have your thumbnails and photos. I have another page if you want a script that can create thumbnails and/or put a tagline on your photos.
This page describes a PHP script that can be used to create an HTML table of thumbnailed images. There are two ways to make use of the create HTML table PHP script.
First Method:
Copy and paste the "loops logic" from the create HTML table PHP script. It is marked in the comments of the script, roughly from lines 55 to 135. Substitute my variables with your variables and that's about it. Change the thumbnails to straight images or other items if you don't want thumbnail images.
Second Method:
Creating HTML pages one at a time on your development machine for later upload to a server.
- Copy the two files "create-html-table-form.txt" and "create-html-table-action.txt" to your local machine. This is not a service for you to use.
- Save them in the same directory somewhere near your photos in web-server directory that is set up with PHP. One directory up from your target photo directories would be a very convenient spot.
- Change the name of "create-html-table-form.txt" to "create-html-form.html".
- Change the name of "create-html-table-action.txt" to "create-html-table.php".
- You need to edit them for your own file structure and delete my leftover stuff. Any text editor will do.
- If you don't have a series of photo pages, delete the series-specific stuff as well.
- And if you don't have thumbnails, you'd want to change the items in the table from links to straight HTML image (or object) elements (tags).
- Browse to the "create-html-table.html" file, fill in the blanks and click the button.
- You should have a formatted HTML-table-web-page-thing. Use the "File..Save As" type of command to save it where you want it. Save as "HTML Only" and NOT "Web Page Complete".
Mistakes I make. After not using it for a while, I'll browse to the "create-html-table-form.html" file with a web browser and wonder why it doesn't work. The answer is I can't browse to it in the file system. You need to go through http://localhost/path/from/document/root to get the server and php engine to kick in. Yup. Done that more than once. Also, to avoid making copies of the script, I'll keep it in a higher directory and target several new directories at once. The page it creates will not have any pictures viewable until after you save it to the proper directory and reload it. I'm getting pretty good at remembering that now...
What's good about this script.
- No cutting and pasting or formatting chunks. You don't have to count photos.
- A lot less typing and chance of typos. The files are read from an array.
- Everything looks consistent without remembering anything.
- Perfect follow-up to the perl scripts.
- Works for me.
What's not good about this script.
- Little or no error handling.
- It's too long. The directory links should be modularized to a function or object method.
- There are two files involved. It should all be one self-contained PHP file. (Meh, it's long enough already. I like the action separate).
- Tell me.
Did I mention, It is not set up to work over the net?

