Opomba:
The user interface has been simplified in Dreamweaver CC and later. As a result, you may not find some of the options described in this article in Dreamweaver CC and later. For more information, see this article.
Your application can contain a set of pages that lets users delete records in a database. The pages normally consist of a search page, a results page, and a delete page. A delete page is usually a detail page working in tandem with a results page. The search and results pages let the user retrieve the record and the delete page lets the user confirm and delete the record.
After creating the search and results pages, you add links on the results page to open the delete page and then build a delete page that displays the records and a Submit button.
When users want to delete a record, they must first find that record in the database. Accordingly, you need a search and a results page to work with the delete page. The user enters search criteria in the search page and selects the record on the results page. When the user clicks the record, the delete page opens and displays the record in an HTML form.
After creating the search and results pages, you must create links on the results page to open the delete page. You then modify the links to pass the IDs of the records the user wants to delete. The delete page uses this ID to find and display the record.
-
(ColdFusion) In the Link box in the Property inspector, add the following string at the end of the URL:
?recordID=#recordsetName.fieldName#
The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can make up any name you like). Note the name of the URL parameter because you'll use it in the delete page later.
The expression after the equal sign is the value of the parameter. In this case, the value is generated by a ColdFusion expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the ColdFusion expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes:
confirmDelete.cfm?recordID=#rsLocations.CODE#
When the page runs, the values of the recordset's CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:
confirmDelete.cfm?recordID=CBR
-
?recordID=<?php echo $row_recordsetName['fieldName']; ?>
The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can make up any name you like). Note the name of the URL parameter because you'll use it in the delete page later.
The expression after the equal sign is the value of the parameter. In this case, the value is generated by a PHP expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the PHP expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes:
confirmDelete.php?recordID=<?php echo $row_rsLocations['CODE']; ?>
When the page runs, the values of the recordset's CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:
confirmDelete.php?recordID=CBR
-
?recordID=<%=(recordsetName.Fields.Item("fieldName").Value)%>
The question mark tells the server that what follows is one or more URL parameters. The word recordID is the name of the URL parameter (you can make up any name you like). Note the name of the URL parameter because you'll use it in the delete page later.
The expression after the equal sign is the value of the parameter. In this case, the value is generated by an ASP expression that returns a record ID from the recordset. A different ID is generated for each row in the dynamic table. In the ASP expression, replace recordsetName with the name of your recordset, and replace fieldName with the name of the field in your recordset that uniquely identifies each record. In most cases, the field will consist of a record ID number. In the following example, the field consists of unique location codes:
confirmDelete.asp?recordID=<%=(rsLocations.Fields.Item("CODE").Value)%>
When the page runs, the values of the recordset's CODE field are inserted in the corresponding rows in the dynamic table. For example, if the Canberra, Australia, rental location has the code CBR, the following URL is used in the Canberra row in the dynamic table:
confirmDelete.asp?recordID=CBR
-
A special link surrounds the selected text. When the user clicks the link, the Go To Detail Page server behavior passes a URL parameter containing the record ID to the specified delete page. For example, if the URL parameter is called recordID and the delete page is called confirmdelete.asp, the URL looks something like the following when the user clicks on the link:
http://www.mysite.com/confirmdelete.asp?recordID=43
The first part of the URL, http://www.mysite.com/confirmdelete.asp, opens the delete page. The second part, ?recordID=43, is the URL parameter. It tells the delete page what record to find and display. The term recordID is the name of the URL parameter and 43 is its value. In this example, the URL parameter contains the record’s ID number, 43.
After completing the page listing the records, switch to the delete page. The delete page shows the record and asks the user if they're sure they want to delete it. When the user confirms the operation by clicking the form button, the web application deletes the record from the database.
Building this page consists of creating an HTML form, retrieving the record to display in the form, displaying the record in the form, and adding the logic to delete the record from the database. Retrieving and displaying the record consists of defining a recordset to hold a single record—the record the user wants to delete—and binding the recordset columns to the form.
Opomba:
The delete page can contain only one record-editing server behavior at a time. For example, you cannot add an Insert Record or an Update Record server behavior to the delete page.
-
-
Complete the Filter section as follows to find and display the record specified in the URL parameter passed by the results page:
From the first pop‑up menu in the Filter area, select the column in the recordset containing values that match the value of the URL parameter passed by the page with the Delete links. For example, if the URL parameter contains a record ID number, select the column containing record ID numbers. In the example discussed in the previous section, the recordset column called CODE contains the values that match the value of the URL parameter passed by the page with the Delete links.
From the pop‑up menu beside the first menu, select the equal sign, if not already selected.
From the third pop‑up menu, select URL Parameter. The page with the Delete links uses a URL parameter to pass information to the delete page.
In the fourth box, enter the name of the URL parameter passed by the page with the Delete links.
-
Select the recordset columns (record fields) in the Bindings panel, and drag them to the delete page.
Make sure you insert this read-only dynamic content within the form boundaries. For more information on inserting dynamic content in a page, see Make text dynamic.
Next, you must bind the record ID column to the hidden form field.
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.
-
-
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.