Monday Evenings, 6:30-9:30pm, Starting February 22nd

Instructor: Bruce Donald Campbell

Faculty, Continuing Education - RISD, Providence, RI
Director, Watersheds Project, Providence, RI

Email: bcampbel01@risd.edu

Prerequisites: HTML and/or Dreamweaver course


This course provides students with an orientation and introduction to dynamic content generation using PHP. Dynamic content creation entails storing dynamic data in a back-end database and querying that data for presentation in XHTML. We use MySQL as a popular open-source relational database management system.


Class participation - 20%
Homework exercises - 20%
One class project - 60%



The recommended book for this class is the third edition of the book PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide, by Larry Ullman (December 2007).

Course Handouts and On-line Readings as identified below and in class




course overview

  • Course Introduction & Policies
  • Instructor and Student Introductions
  • Opening Survey of Student Skills
  • How PHP fits into the Big Picture of the Web
  • Comparative Web Page Examples (PHP, HTML, XHTML, Flash)
  • Syntax Review / Introduction
  • Managing HTML and PHP a text files
  • HTML Document Structure Review


Be sure to read the Welcome to Class page and integrate all we went over together in our first class into your approach for this class.

Look at our class book companion site at: http://www.dmcinsights.com/phpmysql3/.

Let's discuss the role of PHP on which so many Content Management Systems have been built (Drupal, Wordpress, Joomla, Moodle were some of the popular original ones)

Look at the three prior student projects that added functionality to websites with PHP:


php basic data types

  • Master the syntax of simple PHP statements
  • Learn about data types
  • Learn about variables
  • Try some mathematical statements
  • Learn how to install a case study in MAMP (SQL here)
  • In class examples are here.
  • The Include and Require Statements
  • PHP Simple Data Types
    • Numbers (int and float)
    • Text (char and string)
    • Boolean
  • Variables
    • What is a variable?
    • Variable Naming Conventions
    • Assignment statements and Weak Typing (versus Strong Typing)
  • Syntax for Mathematics and Precedence
    • Mathematical Operators
    • Mathematical Assignment and Output Statements
  • Some Exercises that Demonstrate Skills Learned


  • Read Chapter 1 of our book
  • Get WAMP, MAMP, XAMP, or LAMP working on your development system


Investigating an expansive use of PHP


  • Consider how all websites can take advantage of the usability and rich features base of PHP and MySQL (or any back-end database)

Lecture this week is via video:
1. PHP use in Stylesheets
2. PHP with XML (Scalable Vector Graphics)
3. PHP with X3D Integration
4. PHP use with External Web Services
5. Amazon ISBN External API
6. PHP with JavaScript
7. PHP with Regular Expressions

We will work with the code available in the lecture notes for the week.


  • Investigate the examples provided in the class videos


block statements and conditions

In-class examples are online here.


  • Take a look at the Artist Gallery Page in detail.
  • Learn about comparison and logical operators
  • Learn about the If/Else construction
  • Master the syntax of block statements


  • Comparison Operators / Boolean Statements
  • Logical Operators
  • If / Else Blocks
  • Basic For and While Blocks
  • Some Exercises that Demonstrate Skills Learned



Loops and Strings

The on-line lecture associated with this class is on-line here.

In class:

  • Learn about for, do-while and while loops
  • Master the postfix increment and decrement operators
  • Discover the difference between single and double quotes
  • Take a look at FPDF and try an example in class.
  • We will work with the code from the class videos.


  • Consider the syllabus for the remainder of our class and be ready to discuss issues you have with the approach we're taking toward project work.


Arrays, Functions and the "foreach" loop

The on-line lecture associated with this class session is on-line here.


  • Learn about arrays in PHP
  • Learn what a function is and what it does
  • See how functions can be used in other statements
  • Introduction to Lists
  • One-dimensional Arrays
    • Dynamic Arrays (using the array() function)
    • Static Arrays with Numeric Indices and the Array Access Operator
    • Associative Arrays and the Arrow Operator
    • Variables in Array Accesses
  • Writing and Reading Files
  • Introduction to Pre-Defined Functions
  • The count() function
  • Some Exercises that Demonstrate Skills Learned


  • Explore the online PHP documentation
  • Read Chapter 11 of our book


Form Handling and Predefined Variables

The on-line lecture associated with this class session is on-line here.


  • Introduction to the String library
  • Review HTML form creation
  • Learn how to respond to a form in PHP (safely)
  • Learn about predefined global variables in PHP
  • Learn a little bit about type-casting
  • Introduction to Forms
  • Review of HTML forms
    • Creating Forms and Form Elements
    • Actions and Submission Methods
  • PHP's Pre-Defined Form Variables
  • The import_request_variables() function
  • Checking Input Values
    • The isset() function
    • Type-casting
    • Using the null Comparison
  • Overview of Cookies
  • Setting and Retrieving Cookies in PHP
  • Overview of Session Management
  • Setting and Retrieving Session Variables
  • Some Exercises that Demonstrate Skills Learned



Classes, Objects, and Databases

The on-line lecture associated with this class session is on-line here.


  • Understand how an object-oriented scripting language works.
  • Review examples of using classes to create objects with PHP.
  • Investigation of the phpmyadmin interface in terms of classes and objects.
  • Discussion of class goals and preparation for two week hiatus.
  • Some Exercises that Demonstrate Skills Learned



Introduction to databases (Part 1)

The on-line lecture associated with this class session is on-line here.


  • Learn what a database is, and why it works so well with PHP
  • Learn how to create a database and some simple database tables in sqlYog
  • Database Overview
    • Flat, Relational, Object, and Hybrid Databases
    • Database Role in the Big Picture of the Web
    • Database Tables as Columns and Rows
    • Database Records and Field Data Types
    • Structured Query Language and MySQL as one Implementation
    • Structured Query Language (SQL) Syntax
    • Preview of INSERT, UPDATE, and DELETE
  • Some Exercises that Demonstrate Skills Learned



Introduction to databases (Part 2)

The on-line lecture associated with this class session is on-line here.


  • Hear about the 4 most common SQL statements (SELECT, INSERT, UPDATE, and DELETE)
  • We'll take a look at data for a social mediated Partner site available here.
  • Study the SELECT statement in detail
  • Connecting to a database in PHP
  • Let's all use SQL to build some tables again
  • Take a look at MySQL Data Types
  • Let's fill our tables with data
  • Let's integrate our data needs with PHP
  • Adding a Conditional WHERE Clause to Filter Data
  • Integrating Databases with PHP Code
  • The mysql_connect() function
  • The mysql_query() function
  • Result sets, mysql_fetchArray, and while loops
  • Some Exercises that Demonstrate Skills Learned


Putting everything together

Week 10's lecture notes are online.


To feel comfortable with adding a back-end database into an existing website

In Class:



project discussion

  • Consider how the additional features of PHP listed below could be used to your advantage in building attractive and useful websites
  • Getting Comfortable with Self-Guided Learning in PHP
  • Review concepts from list below (with online support here)
The following is a brief listing of some of the topics from which students suggested topics for further investigation. One goal of this course is for you to feel comfortable diving in to any possible topic on your own - have you figured out your own personal process for that yet?
  • Introduction to regular expressions
  • Using regular expressions to extract data from text
  • Filtering incoming values based on regular expressions
  • Complex array handling
  • Using nested arrays and nested associative arrays
  • Array management functions (push, pop, split, merge, etc)
  • Array sorting
  • Complex variable usage
  • Dynamic / run-time variable names
  • Parsing variables from strings and arrays
  • Type checking and manipulation (gettype function and type casts)
  • Classes and objects in PHP
  • Advanced database queries
  • SQL JOINs and cross-referencing multiple tables in a single query
  • Sub-queries
  • Computed columns (and the GROUP BY clause)
  • PHP outside HTML
  • PHP in stylesheets
  • Command-line / Stand-alone PHP applications
  • Generating JavaScript with PHP
  • PHP and dynamic HTML
  • Creating re-usable DHTML chunks
  • Browser detection and dynamic page adaptation on the server
  • Implementing simple administrative areas
  • Security considerations
  • Managing users and permissions
  • Logging changes
  • Gathering website statistics (PHP's original use!)
  • Page views
  • Links and navigation paths
  • Entry and exit pages
  • Error handling in PHP
  • User generated errors
  • Custom error handling functions
  • Stack trace functions
  • Try-catch blocks
  • Exceptions and exception classes

Turn in your project by 11:59pm on May 20th.


Projects Due


  • Finish your Projects for your personal portfolio - due May 20th at 11:59pm