Display the Latest Travel Destination
Display the Latest Travel Destination
The homepage of the site will display the latest travel destination entered in the database. To achieve this you must:
- Create a recordset that retrieves the destinations.
- Display a travel destination on the homepage.
Create the Recordset
A recordset is a set of records from a database tableāin this particular case, a set of vacation destinations. In Dreamweaver, you can either create a recordset using its dialog box, or enter the SQL code yourself.
To create the recordset that retrieves the latest travel destination from the corresponding table, follow the next steps:
- Open the index.php file.
-
In the Application tab, click the Bindings tab to display it.
Figure 10. Click the Bindings title to open the tab
-
Click the Plus (+) button and select the Recordset (Query) option.
Figure 11. Create a new recordset option
-
The basic recordset dialog box displays. Fill in the options as follows:
- In the Name text box, enter rsDestination (the recordset name).
- In the Connection pop-up menu, select the connTravel database connection created at the beginning of the tutorial.
- The Table pop-up will display the only table in the database: destination_dst. Select it.
- In the Sort pop-up menu select date_dst. For the method select Descending.
- Click OK to close the dialog box and create the recordset.
Figure 12. Configure the recordset properties
The newly created recordset displays in the Bindings tab. Expand it to see the columns it retrieves:
Figure 13. Expand the recordset to see the columns it retrieves
Now that you created the recordset, you can move on and display information from it on the page.
Display Dynamic Data
The description text displays in the center column of the template page, replacing the bogus content. To make space for the dynamic field, follow the next steps:
- Open the index.php file.
-
Delete the content from the center column: select it (including the title) and press Delete. You should then have a layout as in figure 15.
Figure 14. Empty table after removing content
-
Click inside one of the table cells in the center and click the Table tag in the Tag Selector.
Figure 15. Select the table containing the TD
-
Using the Property inspector, set the table width to 650 pixels.
Figure 16. Set the table width using the Property inspector controls
-
Drag the
name_dst
field from the Bindings tab into the first table cell:Figure 17. Display the travel destination name
-
To display the description, drag the corresponding recordset field from the Bindings tab into the second table row. The result is like figure 17:
Figure 18. Dynamic text in the center column
Save the page and press F12 to preview it. The default entry displays:
Figure 19. The description displays on the page
Now that display is out of the way, you can move on and create the page that allows editing database information.
Comments