Dreamweaver CS4 Resources
|
Add logic to delete the record
After displaying the selected record on the
delete page, you must add logic to the page that deletes the record
from the database when the user clicks the Confirm Deletion button.
You can add this logic quickly and easily by using the Delete Record
server behavior.
To add a server behavior to delete the record (ColdFusion, PHP)- Make sure the ColdFusion or PHP delete
page is open in Dreamweaver.
- In the Server Behaviors panel (Window > Server
Behaviors), click the Plus (+) button, and select Delete Record.
- In the First Check If Variable Is Defined box, make sure
Primary Key Value is selected.
You specify the primary key value later in the dialog box.
- In the Connection or Data Source (ColdFusion) pop‑up
menu, select a connection to the database so that the server behavior
can connect to the affected database.
- In the Table pop‑up menu, select the database table that
contains the records that will be deleted.
- In the Primary Key Column pop‑up menu, select the table
column that contains record IDs.
The Delete Record server behavior searches this column
for a match. The column should contain the same record ID data as
the recordset column you bound to the hidden form field on the page.
If
the record ID is numeric, select the Numeric option.
- (PHP) In the Primary Key Value pop‑up menu, select the
variable on your page that contains the record ID identifying the
record to be deleted.
The variable is created by your hidden form field. It has
the same name as the name attribute of the hidden field and is either
a form or URL parameter, depending on the form’s method attribute.
- In the After Deleting, Go To box, or the On Success,
Go To box, specify a page to open after the record has been deleted
from the database table.
You can specify a page that contains a brief success message
to the user, or a page listing the remaining records so that the
user can verify that the record has been deleted.
- Click OK, and save your work.
To add a server behavior to delete the record (ASP)- Make sure the ASP delete page is open
in Dreamweaver.
- In the Server Behaviors panel (Window > Server
Behaviors), click the Plus (+) button, and select Delete Record.
- In the Connection pop‑up menu, select a connection to
the database so that the server behavior can connect to the affected
database.
Click the Define button if you need to define a connection.
- In the Delete from Table pop‑up menu, select the database
table that contains the records to be deleted.
- In the Select Record From pop-up menu, specify the recordset
that contains the records to be deleted.
- In the Unique Key Column pop-up menu, select a key column
(usually the record ID column) to identify the record in the database
table.
If the value is a number, select the Numeric option. A
key column usually accepts only numeric values, but sometimes it
accepts text values.
- In the Delete By Submitting pop-up menu, specify the
HTML form with the Submit button that sends the delete command to
the server.
- In the After Deleting, Go To box, specify a page to open
after the record has been deleted from the database table.
You can specify a page that contains a brief success message
to the user, or a page listing the remaining records so that the
user can verify that the record has been deleted.
- Click OK, and save your work.
Test your delete pages- Upload the search, results, and delete
pages to your web server, open a browser and search for a disposable
test record to delete.
When you click a Delete link on the results page, the delete
page should appear.
- Click the Confirm button to delete the record from the
database.
- Verify that the record has been deleted by searching
for the record again. The record should no longer appear in the
results page.
|