Dating database example
In Chapter 1: Installation, we installed and set up two software programs: the Apache web server with PHP, and the My SQL database server.
In this chapter, we’ll learn how to work with My SQL databases using Structured Query Language (SQL).
If you’d rather read this tutorial offline, you can download the chapters in PDF format.
As I explained in that chapter, PHP is a server-side scripting language that lets you insert into your web pages instructions that your web server software (in most cases, Apache) will execute before it sends those pages to browsers that request them.
In a brief example, I showed how it was possible to insert the current date into a web page every time it was requested.
Now, that’s all well and good, but things really become interesting when a database is added to the mix.
In this chapter, we’ll learn what a database is, and how to work with your own My SQL databases using Structured Query Language.
In this example, the jokes would be stored entirely in the database.
The advantages of this approach would be twofold: First, instead of having to write an HTML page for each of your jokes, you could write a single PHP script that was designed to fetch any joke from the database and display it by generating an HTML page for it on the fly.
Second, adding a joke to your web site would be a simple matter of inserting the joke into the database.
The PHP code would take care of the rest, automatically displaying the new joke along with the others when it fetched the list from the database.
Let’s run with this example as we look at how data is stored in a database.