Although PHP can read and write files on a web server, in practice it is much more useful to use a database for data storage and retrieval. MySQL is a popular open source relational database management system (DBMS) that is widely used by web applications. This lesson covers how to access a MySQL database using PHP’s MySQL extensions.

Learning Objectives

  • Connect to a database using PHP
  • Use a prepared statement to execute queries using PHP

How to Complete this Lesson

  1. Complete the following W3Schools tutorials (these have multiple parts):
    • PHP Advanced (20–30 minutes)
    • PHP MySQL Database (15–20 minutes)
      • Focus on the object-oriented MySQLi syntax, which will be used elsewhere in this course, and ignore the other examples
  2. Optional: Complete W3Schools’s PHP Quiz to test your understanding of PHP (10–15 minutes)
  3. Complete the practice exercises (45–90 minutes)
  4. Reply to one of your classmates’ posts in the discussion forum (30 minutes)
  5. Work on the web development programming exercise (PEX) (120 minutes)
    • Pass all the automated tests for the website
    • Create a CSS theme for consistent presentation across the website

Due

As a reminder, the following is due this lesson: