The four methods for managing databases are as follows (with the easiest method on the left and hardest on the right):
- SQL command line
- MS-DOS style command line
Most web developers mainly using the first two methods, but not the MS-DOS-style command line. For interactive databases, you will need some PHP files. You do not need an extensive knowledge of PHP before you can create interactive databases. I introduce the PHP you require in the appropriate place in each project—that is, in context. The step-by-step, fully-worked examples will show you what MySQL and PHP can do and how to do it.
Because of its popularity, GUIs (mouse operated Graphical User Interfaces) have been developed to facilitate the task of developing databases. These are known as development platforms, and the platform used throughout this book is XAMPP.
A Brief Look Inside the Machinery
Databases need a server, a database program, and a PHP processor as shown in Figure 1. These can be downloaded as an all-in-one, ready-configured package. The testing and development of the projects in this book are based on the free XAMPP package that is available for all operating systems.
Figure 1. A diagram of the machinery for passing database information to and from users
Figure 1-1 shows the main components built into the XAMPP development platform. They are as follows:
- Apache is the web page server used by the great majority of hosts and on local computers for developing databases. PHP files and databases need a server in order to work.
- MySQL is the database, and it provides management tools.
- The PHP processor checks for errors and processes the PHP files that are needed to make databases interact with users.
- phpMyAdmin is a mouse-operated program for creating and maintaining databases and their tables.
A single all-in-one package such as XAMPP contains the four programs and is called a WAMP (Windows, Apache, MySQL, and PHP). In WAMPs such as XAMPP, the main components are preconfigured so that they can talk to each other. The equivalent on a Mac computer is MAMP, and on a Linux computer it is LAMP.
The folder htdocs is part of XAMPP and is the storage area for your web pages. Apache and MySQL, by default, look in htdocs for your web pages. These pages may be designed to allow users to interact with the database. Other pages will operate unseen as they transmit information back and forth between user and database. The pages are usually HTML and PHP files or a combination of both.
Caution Everything inside the envelope in the diagram shown in Figure 1 will be already installed on a remote host, but you should never use a remote host to create a database while you are learning. For security reasons, do not use a remote host until you have become proficient. Always learn and develop a database using a WAMp on your own computer. note that a WAMp installed on your own computer is purely a development tool. The database, when developed and thoroughly tested, can eventually be uploaded to a host to make it available to users.
A Free Development Platform for Testing
You will not be able to test your work in the normal way - that is, by using a browser to view a database and PHP files located on your hard drive. However, you can develop, test, and view your database and PHP files by using a WAMP on your computer. This book assumes that you will use XAMPP on your own computer while you are learning, and for developing future database-driven websites.
I have omitted instruction on the EASYPHP and WAMPServer programs to save space; they are very similar and are as effective as XAMPP. I use XAMPP because I am used to it, and I think the interface is slightly better than the others (my opinion only).