Resources

CSS, the Missing Manual David Sawyer McFarland
PHP and MySQL Larry Ulman
Manga Guide to Databases Shoko Azuma

useful programming resources

W3 Schools programming resources

Tiztag programming resources

About.com

Web site security rules

Learning Ruby, an interactive Guide

An HTML validation tool, Very Important

Lists and CSS styles elegantly explained

Step by step lessons in PHP programming


Useful tools

Text Wrangler - General Purpose text editor

Transmit Text Edit and FTP client

The Total Validator validation tool


A Script for success

Web Page scripts are the engine that makes for internet interactivity. A basic web page, like this one, is essentially a one time visit. You look at the page, and move on. But even a simple web page like this one can use scripts, and this one uses several. Scripts can live either on the Server side, which is where all the processing for the script takes place on the computer which hosts the web page, or on the client side, where the processing takes place on the users own computer. Perl and PHP are both Server side scripts. Javascript is a client side script. The trend now is to harness them together.

Scripts do what computers are good at: Taking complex repetitive tasks off the hands of the web page writer and allowing more time to concentrate on content and allow the computer to do more of the work of structure. For instance, there is the little matter of the navigation bar at the bottom of this page. Every time I update the site, I change the menu bar. Right now we are at page 11 of what looks like becoming a very complicated site. Changing every page as I finish each page would be tedious and prone to error. Instead, I have a script that takes care of inserting the navigation. When I finish a page, I just change one file, rather than eleven.

<?php
for($loop=2; $loop<=11; $loop; ++)
{
if (!($loop==$page))
echo "<a href=\"http://uncletoby.net/coolpage".$loop.".php\"> $loop </a>|";
}
?>

This looks complicated, but the pieces are actually very simple. The The first statement is a "for loop." It establishes an initial condition, in this a variable called $loop is set to 2, and while loop is less than or equal to 11, the loop repeats. And each time the loop repeats, loop is increased by one. Outside of this code snippet I set the $page variable. If the $loop variable is the same as the page variable, the next line is skipped. Otherwise, it creates the link for each page in order. If you look at the source page for this page, you will see each link arranged in order. Building those links manually page after page would turn a fun learning project into a mind numbing chore. There is also the point of easy maintenance. The resources bar is another short script. It is of a level of complexity where we will dissect it in a page further along. The resources script reads from a data base of resources, categorizes them, and places them in a set order. I can add resources as time goes by, of any particular type, but the script will categorize them nicely on the page.

The real glory of PHP scripts is how they integrate the MySQL information into the web page. They are the bridge between the two technologies. There are other technologies that also do the same job but PHP is easy to learn and very powerful.

PHP code is the bridge that brings information from your data base and makes it dynamic on your web page. It is an interpreted scripting language that produces web pages. It is a server side When a request is sent to the web site, the script is interpreted at the host computer. Your user never sees the php code, only the web page.

Javascript is another scripting language for dynamic web pages. Javascript lives on the client computer. When the page loads into your browser, the web browser interprets the script as it builds the page. Javascript is used for validation prior to sending the form to the server.

There is a new technology that integrates both of them together very nicely called AJAX. You see AJAX in action when you type into the google search bar.

One of the things PHP scripts do is help automate the process of getting MySQL information back to the user. MySQL is a powerful database language, but you don't want casual users of your web site putting there own things into it, and aspects of it are not friendly to the casual user. For instance, on the first page of this website, we have a small search field, so that you can find a book by author or title when you know just a small bit of either piece of information.

Search Here

The script sends two queries to the data base, then prints them in order. Lets look at them. The first thing to notice is that the user enters in the search string, which the script evaluates and then sends to the MySQL engine. I am going to use the search string "West." Here is one of the two MySQL statements:

mysql> select books.title as title, 
concat(authors.efname,' ',authors.elname) as scribe,
Topics.topic as subject from books
inner join bookswritten using(book_id)
inner join authors using(writer_id)inner 
join Topics using(Topic_id) where 
authors.elname like "West%"
order by authors.elname, books.title;
+----------------+-----------------+--------------+
| title          | scribe          | subject      |
+----------------+-----------------+--------------+
| High Adventure | Donald Westlake | Romance      | 
| Humans         | Donald Westlake | Fantasy      | 
| Kahawa         | Donald Westlake | Spy Thriller | 
| Why me?        | Donald Westlake | Mystery      | 
+----------------+-----------------+--------------+

The script permits us to automate the whole of the request. I think a lot of us faced with trying to enter that MySQL request into the computer to get the information would rather just wander the shelves on the off chance of finding what they are looking for. The script makes finding the information a lot faster.

The particular script here looks for both title and author information. This script does two MySQL requests, one for author's last names that start with a particular string or set of letters, and the other which searches for that string anywhere in the title.

Among other great features of scripting languages is that they can integrate together. A web page will often have several different scripts woven together. There will be jave scripts and PHP scripts interspersed in the HTML as the need arises.

| page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 |