Specifications
4. The MySQL server receives the database query, processes it, and sends the results—a list
of books—back to the PHP engine.
5. The PHP engine finishes running the script that will usually involve formatting the query
results nicely in HTML. It then returns the resulting HTML to the Web server.
6. The Web server passes the HTML back to the browser, where the user can see the list of
books she requested.
Now we have an existing MySQL database, so we can write the PHP code to perform the pre-
vious steps. We’ll begin with the search form. This is a plain HTML form. The code for the
form is shown in Listing 10.1.
LISTING 10.1 search.html—Book-O-Rama’s Database Search Page
<html>
<head>
<title>Book-O-Rama Catalog Search</title>
</head>
<body>
<h1>Book-O-Rama Catalog Search</h1>
<form action=”results.php” method=”post”>
Choose Search Type:<br>
<select name=”searchtype”>
<option value=”author”>Author
<option value=”title”>Title
<option value=”isbn”>ISBN
</select>
<br>
Enter Search Term:<br>
<input name=”searchterm” type=text>
<br>
<input type=submit value=”Search”>
</form>
</body>
</html>
This is a pretty straightforward HTML form. The output of this HTML is shown in
Figure 10.1.
Accessing Your MySQL Database from the Web with PHP
C
HAPTER 10
10
ACCESSING
YOUR MYSQL
DATABASE
229
13 7842 CH10 3/6/01 3:36 PM Page 229