Specifications
Disconnecting from the Database
You can use
mysql_close(database_connection);
to close a nonpersistent database connection. This isn’t strictly necessary because they will be
closed when a script finishes execution anyway.
Putting New Information in the Database
Inserting new items into the database is remarkably similar to getting items out of the database.
You follow the same basic steps—make a connection, send a query, and check the results. In
this case, the query you send will be an INSERT rather than a SELECT.
Although this is all very similar, it can sometimes be useful to look at an example. In Figure
10.3, you can see a basic HTML form for putting new books into the database.
Using MySQL
P
ART II
238
FIGURE 10.3
This interface for putting new books into the database could be used by Book-O-Rama’s staff.
The HTML for this page is shown in Listing 10.3.
L
ISTING 10.3
newbook.html—HTML for the Book Entry Page
<html>
<head>
<title>Book-O-Rama - New Book Entry</title>
</head>
13 7842 CH10 3/6/01 3:36 PM Page 238