The links on the results page (see Creating links to a confirmation page (PHP)) not only have to open the confirmation page, they must pass the ID of the record the user wants to delete. The confirmation page will use this ID to find the record in the database and display it.
You must pass the record ID to the confirmation page with a URL parameter. This section describes how to create a URL parameter to pass the record ID to the confirmation page.
If Live Data is turned on, select the link in the first row.
?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 confirmation 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, then the following URL will be used in the Canberra row in the dynamic table:
confirmDelete.php?recordID=CBR
After creating a dynamic URL parameter for the delete links, the next step is to display the record on the confirmation page. See Displaying the record on the confirmation page (PHP).