Practical PHP and MySQL

Chapter 2

This chapter was an introduction to working with PHP and included several exercises.

Exercises

Using HTML within PHP
Using PHP tags within HTML
Using Variables
Setting a variable and calling it multiple times
PHP as a Simple Calculator
Part 1 – addition
Part 2 – division
Part 3 – rounding up and down
The for Loop
Looping through and echoing numbers
The while Loop
Checking a condition and looping
The if Statement
Testing for a condition
The if…else Statement
Testing for a condition, with a fallback if the condition is false
The switch Statement
Testing multiple conditions at once
Using Functions
A simple function
Working with Forms
Taking information from a form
Iterating Through the Results
Taking information from a database and displaying it on a page
Using Session Variables
This doesn't really work on my site