O'Reilly logo
live online training icon Live Online training

Getting started with PHP and MySQL

Beginning custom dynamic web development

Peter MacIntyre

Do you want to learn basic dynamic web development but don’t know where to begin? Maybe you know a little about HTML and CSS, but the bigger picture eludes you. Or you want to connect your site's content to a database so that you can update it without having to change the code files. If so, this is the course for you.

In this hands-on four-hour course, Peter MacIntyre teaches you the ins and outs of PHP—one of the world's most popular web development languages—and details the interaction with databases it offers. Sign up to get hands-on experience using SQL database interaction and programming constructs, loops, and arrays as you explore this powerful language.

What you'll learn-and how you can apply it

By the end of this live, hands-on, online course, you’ll understand:

  • What PHP is and how to use it
  • How to use variables, arrays, and functions in PHP scripts
  • How to interact with a MySQL database

And you’ll be able to:

  • Process forms and validate submitted information
  • Incorporate cookies and session variables in PHP scripts
  • Add, update, and delete records in a MySQL database using PHP

This training course is for you because...

  • You’re a frontend developer who wants to know what’s going on on the server side.
  • You work with PHP-based websites, and you want to go deeper with database interaction.
  • You want to become a PHP web developer.
  • You want to build data-driven websites.

Prerequisites

  • A working knowledge of HTML and CSS scripting
  • A basic understanding of computer programming
  • A machine with either WAMP, XAMP, or MAMP installed, so you can get a web server with PHP running locally

Recommended preparation:

Install either WAMP, XAMP, or MAMP to get a web server with PHP running locally

Recommended follow-up:

About your instructor

  • Peter MacIntyre has over 28 years of experience in the information technology industry, primarily in the area of PHP and Web Technologies. He has contributed writing material for many IT industry publications: Author of "PHP: The Good Parts" (O’Reilly); co-author: Pro PHP Programming (APress), Programming PHP (3rd Edition - O’Reilly), Using Visual Objects, Using PowerBuilder 5, ASP.NET Bible, Web Warrior Survey on Web Development Languages, and Zend Studio for Eclipse Developer's Guide. Peter has another book covering WordPress that was published in May 2016.

    Peter is a co-founder and past co-chair and past board member for the Northeast PHP Developer's Conference held in Boston, MA and Charlottetown, PE Canada for the last 6 years. Additionally, Peter has spoken several times at North American and International computer conferences including PHPCE 2017 in Warsaw, Poland; PHP[World] 2016 in Washington, DC; ZendCon 2016 in Las Vegas, NortheastPHP 2017 & 2016 (Charlottetown, PE, Canada), Prairie Dev Con 2016 in Winnipeg, MB, Canada, CA-World in New Orleans, USA; CA-TechniCon in Cologne, Germany; and CA-Expo in Melbourne, Australia.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Introduction (10 minutes)

  • Lecture: Introduction to PHP; competing technologies (.NET, JSP, Java, Python, and Ruby)

Basic web concepts (25 minutes)

  • Lecture: The operating system; Apache web server—PHP; MySQL; phpMyAdmin; code text editors (Textpad, Vi, Zend, PHP Storm, etc.); the PHP environment—the client, the server(s)
  • Hands-on exercise: Show phpinfo
  • Q&A

Language basics (25 minutes)

  • Lecture: < ?php … ? > PHP tags, ending commands with ";"; echo & var_dump; ways to comment your code; variables (scalar and array); data types; relational operators; assignment operators
  • Hands-on exercise: Create “Hello, World” PHP code and server it locally
  • Q&A
  • Break (5 minutes)

Logical language constructs (15 minutes)

  • Lecture: If...then...else (elseif); switch...case (break;); comparison ( = =)
  • Hands-on exercise: Use conditions to present different results based on server time being an odd or even number (Output: “The time is 99:99am/pm; this is odd/even.”)
  • Q&A

More server concepts (15 minutes)

  • Lecture: $_POST; $_GET; $PHP_SELF
  • Hands-on exercise: Collect $_GET information from an embedded < a href > HTML tag
  • Q&A

Flow control (30 minutes)

  • Lecture: Do while…; while…; for...next
  • Hands-on exercise: Design a form to calculate the amount of money you have in your change dish (allow for the entry of pennies, nickels, dimes, quarters, 50-cent pieces, and dollar coins); show the totals in both cents and dollars in a printable table; provide a way to return to the coin-entry page if necessary
  • Q&A
  • Break (10 minutes)

PHP functions (10 minutes)

  • Lecture: Built-in functions; a look at php.net; rolling your own functions
  • Q&A

Cookies (10 minutes) Lecture: Why use cookies?; setting cookies; GDPR (General Data Protection Regulation) awareness Q&A

Sessions (30 minutes)

  • Lecture: Why use sessions?; setting sessions; $_SESSION
  • Hands-on exercise: Build a form that collects name and phone number with separate area code filed; process the information via the $_SESSION to determine what area code falls into a certain state
  • Q&A
  • Break (5 minutes)

Dates and times (10 minutes)

  • Lecture: Unix epoch; date functions; time functions
  • Hands-on exercise: Pick up “your” time of day using the previous exercise's code and time zone; calculate the time of day in GMT
  • Q&A

Database interaction (30 minutes)

  • Lecture: SQL crash course; MySQLi; connections; sending queries; managing results; phpMyAdmin tool
  • Hands-on exercise: With provided address table, connect to DB and access records, displaying content; create a table for first name, last name, address, email, and phone number; create a form to collect the information and save it to the database table; create another form to search the table based on last name OR email OR partial of either and display the results; create a simple menu of links to trigger each of these actions
  • Q&A

Wrap-up and Q&A (10 minutes)