In this tutorial we will create a recordset with which we will display some data from a database. The recordset represents a set of information extracted from a database using a database query. The extracted information can be used afterwards as a source of content for dynamic pages.
In order to be able to follow the tutorial, you will need a MySQL server. You can get the community edition of MySQL from here.
1. The first thing you need to do is to open Dreamweaver and create a new Dreamweaver site. If you have any problems doing that, please refer to the tutorial How to create a Dreamweaver site.
2. Create a new PHP file and save it as recordset.php.
3. By accessing Window>Databases or by pressing Ctrl+Shift+F10, open the Databases panel. Click on the plus-like icon and open the MySQL Connection window. As you can see in the Databases panel, there are three conditions you have to satisfy in order to use dynamic data on the page: to create a site for the file, to choose a document type (PHP) and to setup the site’s testing server. As you fulfill these conditions, a V sign will appear next to the condition.
Open the "MySQL Connection" window
4. Configure the MySQL Connection window by giving the connection name of your choice, the MySQL server name, user name and password (if available) and then select a database existent on the server; as the server I am using runs on the local machine I inserted localhost with the default user root and no password. Also, I have previously created a database entitled test with a table inside.
Configure the "MySQL Connection" window
Select the desired database
5. By accessing Window>Bindings or by pressing Ctrl+F10, open the Bindings panel. By using the plus-like icon, create a Recordset (Query).
Open the "Recordset" window
6. Configure the recordset in the Recordset window; you have to give it a name, to select a connection with a database (or click on Define to create a new one), to select a table from the database and define a query. Click on Test to see how the table content is displayed.
Configure the "Recordset" window
Initial table content
7. Select Sort by product_name, choose Descending and click on Test again to see how the content is affected by the query.
Define a query
Sorted table content
8. Open the Insert panel by selecting Window>Insert or by pressing Ctrl+F2. In the Data section, select and insert a dynamic table.
Open the "Insert" panel
9. I left the configuring options default, as in the image below.
Configure the "Dynamic table" window
10. Press F12 to preview your file in a browser.
Preview your file
Thank you for your time and I hope this tutorial was useful to you. I invite you to read the rest of our tutorials and check out our other products on www.extendstudio.com. If you have any questions, please contact us at email@example.com.