Chapter 4. Querying Web Databases
This chapter is the first of six that introduce practical web database application development. In Chapter 1, we introduced our case-study application, Hugh and Dave’s Online Wines. We use the winestore here to illustrate the basic principles and practice of building commonly used web database components.
In this chapter, we introduce the basics of connecting to the MySQL
DBMS 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.
Queries that are driven by user input into an HTML
<form> or through clicking on hypertext
links are the subject of Chapter 5.
We introduce the following techniques in this chapter:
Using the five-step web database querying approach to develop database-driven queries
Coding a simple solution to produce HTML
<pre>preformatted textUsing the MySQL library functions for querying databases
Handling MySQL DBMS errors
Producing formatted output with the HTML
<table>environmentUsing include files to modularize database code
Adding multiple queries to a script and consolidating the results into one HTML presentation environment
Performing simple calculations on database data
Developing basic database-driven scripts incrementally and producing modular code encapsulated in functions
Our case study in this chapter is the front-page panel from the winestore that shows customers the Hot New Wines available ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access