November 07 PHP & MySQL - Getting Started
Introduction to PHP & MySQL
An XHTML/CSS website can provide a user with information, but cannot provide interaction. In
order to do this, the site must have some form of intelligence that allows it to make decisions,
based on input from the user. Javascript goes some way to doing this, but (apart from cookies,
which have certain limitations), javascript cannot provide the web developer with a way to remem-
ber information that the user provides it - which allows web developers to produce truly interac-
tive, compelling web experiences.
This remembering is most commonly done with a database, a simple storage mechanism for com-
puter data, more capable than a flat file, or a spreadsheet, due to its ability to create relationships
between different sets of data - but more about that later. We are going to be using a database
server called MySQL, which uses standard Structured Query Language (SQL) as the
In order to talk to a database, we need a programming language that can connect to and commu-
nicate with the database, we are using PHP.
PHP in Brief
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic
ODBC, etc.)
PHP is an open source software (OSS)
PHP is free to download and use
What is a PHP File?
PHP files may contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
MySQL is a database server
MySQL is ideal for both small and large applications
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
PHP & MySQL - Getting Started
1
November 07 PHP & MySQL - Getting Started
PHP + MySQL
PHP combined with MySQL are cross-platform (means that you can develop in Windows and
serve on a Unix platform)
Why PHP?
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP is FREE to download from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side
Homework:
Use google to search for each of the functions shown in todays demonstration, then note what they
do and how they do it. Practice creating a few databases, and connecting to them.
Links - Required Reading
W3Schools: PHP Syntax http://www.w3schools.com/php/php_syntax.asp
W3Schools: MySQL Introduction: http://www.w3schools.com/php/php_mysql_intro.asp
W3Schools: PHP MySQL Connect to a Database:
http://www.w3schools.com/php/php_mysql_connect.asp
Data Driven Web Pages:
http://media.wiley.com/product_data/excerpt/8X/07821414/078214148X.pdf
Links - Recommended Reading
Think Vitamin: a resource for web designers, developers and entrepreneurs:
http://www.thinkvitamin.com/
A List Apart: explores the design, development, and meaning of web content, with a special focus
on web standards and best practices: http://www.alistapart.com
Killer PHP: Video (yes, VIDEO!) tutorials for beginners and intermediate:
http://www.killerphp.com/
Links - Further Reading
These links are more comprehensive, and are only recommended if you find the subject material
easy, or wish to dig much deeper, focus on understanding the concepts in the lecture before at-
tempting to read and understand these.
MySQL: The homesite for MySQL: http://www.mysql.com/
PHP.Net: The homesite for PHP, including news, information and the manual: http://php.net/
Wikipedia: SQL entry: http://en.wikipedia.org/wiki/SQL
Wikipedia: MySQL entry: http://en.wikipedia.org/wiki/SQL
Wikipedia: PHP entry: http://en.wikipedia.org/wiki/Php
PHP & MySQL - Getting Started
2
November 07 PHP & MySQL - Getting Started
PHP & MySQL - What to expect from this module
Getting Started Day 1 Introduction To Data Driven Sites
Similarities between Javascript & PHP
MySQL
Connecting to a Database
Code Basics Day 2 PHP & HTML Text
Day 2 PHP Decision Making
Day 3 Functions
Day 3 SQL
Day 4 Arrays
Day 4 Forms
Sessions Day 5 Sessions & Authentication
PHP & MySQL - Getting Started
3