Programming instructions

Enhancing the Trip Maintenance application 125
<cfelseif IsDefined("Form.btnEdit")>
...
<cfelseif IsDefined("Form.btnAdd")>
...
</cfif>
The first two buttons are the easiest to handle because they do not require building any
new pages. Therefore, you will implement the functionality for the
Search and Delete
buttons first.
Linking the Trip Detail page to the Trip Search page
The ColdFusion cflocation tag navigates from the current page to a target HTML or
CFML page. The URL attribute contains the name of the target page and any
arguments. The code to navigate to the search page (tripsearch.cfm) follows:
<cflocation url="tripsearch.cfm">
Deleting the current trip record shown on the Trip Detail page
Before you can write the code to delete a trip, you must understand the underlying SQL
statement to delete rows from the trips table.
SQL DELETE Statement
The SQL DELETE statement removes existing rows in a relational table. The format of
the DELETE statement is as follows:
DELETE FROM table_name WHERE column_name = some_value
Consider a database table named Clients that holds information about people with the
following rows:
To delete everyone from New York from the table, use the following statement:
DELETE FROM Clients WHERE City = 'New York'
After the database management system processed the preceding statement, the table
would contain the following row only:
To ensure that the Trip Maintenance application deletes only the proper trip, you must
use the unique tripID key when issuing the SQL DELETE. The RecordID field holds
the tripID. Therefore, using the hidden
RecordID input tag from the Trip Detail page,
the following SQL statement deletes a row from the Trips table reads:
LastName FirstName Address City
Jones Tom 50 Main St New York
Adamson Anita 521 Beacon St Boston
Green Peter 1 Broadway New York
LastName FirstName Address City
Adamson Anita 521 Beacon St Boston