Chapter 6. Querying Web Databases

This chapter is the first of eight that introduce practical web database application development. In the first section, we introduce the basics of connecting to the MySQL server with PHP. We detail the key MySQL functions used to connect, query databases, and retrieve result sets, and we present the five-step process for dynamically serving data from a database. In the second section, we show you how to drive the queries by user input from an HTML form and by clicking on hypertext links.

The first section of this chapter introduces you to the following techniques:

  • Using the five-step web database querying approach to develop database-driven queries

  • Using the MySQL library functions for querying databases

  • Handling MySQL server errors during development

  • Using include and require files to modularize database code

After we've covered the basics, the second section introduces you to using user data in the querying process. We show you the following techniques:

  • Passing data from a web browser to a web server

  • Accessing user data in scripts

  • Securing an application

  • Querying databases with user data

The final section is a MySQL function reference that explains each library function in detail.

The focus of this chapter is database server and user interaction, not presentation in the browser. Presentation is a subject of Chapter 7. Extended examples of querying that use the techniques of Chapter 6 and Chapter 7 can be found in Chapter 16 to Chapter 20.