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.
-
Click the Plus (+) button and select the Recordset (Query) 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.
The newly created recordset displays in the Bindings tab. Expand it 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.
-
Click inside one of the table cells in the center and click the Table tag in the Tag Selector.
-
Using the Property inspector, set the table width to 650 pixels.
-
Drag the
name_dst
field from the Bindings tab into the first table cell: -
To display the description, drag the corresponding recordset field from the Bindings tab into the second table row. The result is like figure 17:
Save the page and press F12 to preview it. The default entry displays:
Now that display is out of the way, you can move on and create the page that allows editing database information.
Comments